-
Notifications
You must be signed in to change notification settings - Fork 172
Closed
Description
I find this confusing:
Temporal.PlainYearMonth.from('2019-06').add({days: 500}).toString()
// => '2020-10'It seems to leak implementation details: PlainYearMonth is the same as PlainDate but with the day field set to 1 by default. Conceptually, PlainYearMonth is meant to represent the entire month, i.e any day within the month, but adding days assumes that it actually represents the first of the month.
This is true of other fields and data types as well, e.g. you can add hours to a PlainDate, which assumes it is midnight by default.
Temporal.PlainDate.from('2019-06-02').add({hours: 24}).toString()
// => '2019-06-03'I think it would make more sense to be more strict about what fields can be added to each type such that only the smallest field represented by the type is allowed to be added.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels