dayjs icon indicating copy to clipboard operation
dayjs copied to clipboard

dayjs 2.0 question - functionality of QuarterOfYear plugin vs WeekOfYear plugin

Open BePo65 opened this issue 3 years ago • 0 comments

I'm currently implementing the QuarterOfYear plugin for dayjs 2.0 (as a sample for a plugin that overloads existing Dayjs methods). While on it, I noticed that the question of what functionality of a plugin for "new a unit" is implemented in what module is not consistent between different plugins.

To make clear what I want to say, here a little table:

QuarterOfYear WeekOfYear IsoWeek
get / set in plugin (quarter) in plugin (week, weeks) in plugin (isoWeek)
add / subtract in plugin in dayjs core not implemented
diff in dayjs core in dayjs core not implemented
startOf / endOf in plugin in dayjs core in plugin (new unit 'isoweek')
remarks plural (weeks) part of plugin no plural in plugin pluralGetSet; no short unit

IMO for dayjs 2.0 we should be more consistent.

The question is: what is the "correct" implementation?
For QuarterOfYear I implemented both ways, but I only created a pr #2053 for the way 'WeekOfYear' does it (just implementing get / set).

So what should we do - stay with the simple get / set implementation of 'WeekOfYear' or change it to the 'full implementation' with all methods implemented in the plugin, overloading the methods in the core module.

BePo65 avatar Sep 03 '22 12:09 BePo65