-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor:(std/datetime) weekOfYear: Use constants, improve readability #6741
Conversation
While working on this, I felt a pull to add a weekOfYear(new Date()); This made me wonder further: what is the defined purpose of |
const DAYS_PER_WEEK = 7; | ||
|
||
enum Day { | ||
Sun, | ||
Mon, | ||
Tue, | ||
Wed, | ||
Thu, | ||
Fri, | ||
Sat, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be exported, or kept private unless/until needed? I didn't see any guidelines about conditions for exporting, keeping exports to a minimal, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggested to remove the currentDayOfYear
in that issue.
As for the purpose of std/datetime
: I think a clear definition has to be worked out still, but I think it is a good addition as a std library. In my view the module has theses purposes at the moment:
- provide commonly used functions related to date and time
- provide datetime parser and formatter
I think some 3rd party libraries do the one, some the other.
I did a PR to add a generic parser and a formatter. In a sense some features are reinventing the wheel (like parser and formatter) but the attention lies to provide compatibility with Intl
.
Also this module will likely change once this proposal is at stage 4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Temporal
looks like a step forward. 🧗
@bartlomieju Any feedback about exports?
Re: fmt I ran: ./tools/format.py from the repo root directory, but it exited with an error. I don't remember the exact error, but I'm wondering if that step can be added to the repo actions, since I'm not the first to run into this problem. Related: Is |
The purpose for
This issue should be resolved when #6682 lands.
No, it's not, current repository uses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thanks!
Related issue: #6601
Related PR: #6659
This PR improves readability for code and documentation.
I noticed the use of literal millisecond and integer values, and an opportunity to remove some comments and improve code readability, so I refactored it, using constants instead of the literals.
The new tests are sourced from moment.js.