Repository navigation
std/temporal: split Y - 1 into century and year in Date.dayOfWeek #608
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,25 @@ ISO 8601 yonks: 0012-11-10 | |
| yonksAgo.year = 12 | ||
| ``` | ||
|
|
||
| The weekday of a year ending in 00 needs the right century. A | ||
| January first or March first of 1900 or 2100 lands on a different day | ||
| than in 2000, since 2000 is a leap year and the others are not. | ||
|
|
||
| for (let y of [1700, 1800, 1900, 2000, 2100, 2400]) { | ||
| console.log( | ||
| "${y}: Jan 1 weekday ${new Date(y, 1, 1).dayOfWeek}, Mar 1 weekday ${new Date(y, 3, 1).dayOfWeek}" | ||
| ); | ||
| } | ||
|
|
||
| ```log | ||
| 1700: Jan 1 weekday 5, Mar 1 weekday 1 | ||
| 1800: Jan 1 weekday 3, Mar 1 weekday 6 | ||
| 1900: Jan 1 weekday 1, Mar 1 weekday 4 | ||
| 2000: Jan 1 weekday 6, Mar 1 weekday 3 | ||
| 2100: Jan 1 weekday 5, Mar 1 weekday 1 | ||
| 2400: Jan 1 weekday 6, Mar 1 weekday 3 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the record, here's an attempt to use $ for y in {17,18,19,20,21,24}00; do echo "$y Jan 1 weekday $(date -j -f "%Y-%m-%d" $y-01-01 +%u), Mar 1 weekday $(date -j -f "%Y-%m-%d" $y-03-01 +%u)"; done
date: nonexistent time
date: nonexistent time
1700 Jan 1 weekday , Mar 1 weekday
date: nonexistent time
date: nonexistent time
1800 Jan 1 weekday , Mar 1 weekday
1900 Jan 1 weekday 1, Mar 1 weekday 4
2000 Jan 1 weekday 6, Mar 1 weekday 3
2100 Jan 1 weekday 5, Mar 1 weekday 1
2400 Jan 1 weekday 6, Mar 1 weekday 3I'm guessing the nonexistent time thing is due to a failure to just use a proleptic Gregorian calendar. My
Java's
And its DayOfWeek.getValue returns the ISO's 1-indexed weekday number starting at 1 = Monday. Here's the output of |
||
| ``` | ||
|
|
||
| TODO: test negative year support once we've got a | ||
| story for Python whose datetime.MIN_YEAR == 1. | ||
|
|
||
|
|
||
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.
Ugh. I probably meant to do something with
~instead of-here.