dayjs 2.0 question - functionality of QuarterOfYear plugin vs WeekOfYear plugin
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
Research direction
Compare the QuarterOfYear, WeekOfYear, and IsoWeek plugins with the corresponding Day.js core methods. Determine and document a consistent ownership model for get/set, add/subtract, diff, and startOf/endOf behavior, then align the implementation and any relevant tests with the agreed design.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- developer-experience
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100