Skip to content

Why have Timestamp hour as largest unit for addition/subtraction? #124

Answered by BurntSushi
snaggen asked this question in Q&A
Discussion options

You must be logged in to vote

Good question. This has a few knots to it, and I suspect one implied aspect of your question is "why doesn't Timestamp support days, but I can round a Span in a way that assumes all days are 24 hours?"

So first, the Timestamp restriction to units of hours or smaller comes from Temporal:

The years, months, weeks, and days fields of duration must be zero. Temporal.Instant is independent of time zones and calendars, and so years, months, weeks, and days may be different lengths depending on which calendar or time zone they are reckoned in. This makes an addition with those units ambiguous. To add those units, convert the Temporal.Instant to a Temporal.ZonedDateTime by specifying the desired…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by BurntSushi
Comment options

You must be logged in to vote
1 reply
@BurntSushi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants