-
Notifications
You must be signed in to change notification settings - Fork 152
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
Easier "midnight" ? #737
Comments
My opinion is that we should stay explicit. I would then personally not be in favor for the omitted parameter defaulting to 00:00, and the guessing that it involves when reading code when the API is not closely familiar. I favor more typing for readability. |
Having midnight be the default for toDateTime() would be consistent with #340. FWIW, |
This is my order of preference:
Even if Providing a function similar to I shared my point of view, I leave space for others:) |
I also think there should be a For reference, in the Apple ecosystem, we have such a method: https://developer.apple.com/documentation/foundation/calendar/2293783-startofday |
One data point in favour of adding this kind of method is that it's very un-obvious to get the start-of-day if that start-of-day is not at 00:00: const zone = Temporal.TimeZone.from('America/Sao_Paulo');
const date = Temporal.Date.from('2015-10-18');
date.toDateTime(Temporal.Time.from('00:00')).toAbsolute(zone).toDateTime(zone)
// ⇒ 2015-10-18T01:00 (see #105 (comment)) In that case I would think it'd be mostly useful to have on the zoned date-time type (#700) since Temporal.Absolute doesn't have the concept of a start-of-day, and with Temporal.DateTime the start-of-day is always 00:00 by definition because it doesn't have the concept of a time zone. |
Sounds good. Unless there are objections, I'll add a BTW another minor thing in the |
* Per tc39#737, adds property to get first valid time at or after midnight * Fixed bug in `hoursInDay` property getter * FIxed docs for `isTimeZoneOffsetTransition` property * Added DST-focused tests for all three properties * Also added tests for `toLocalDateTime` methods on other types
OK, |
It seems we've definitely had feedback that |
This arises from a need identified in feedback to have a more ergonomic way to get a Temporal.DateTime with midnight on a certain date. Closes: #737
We have not discussed this yet, but I've made a speculative PR that will hopefully spark either a positive or negative reaction: #860 |
* Per tc39#737, adds property to get first valid time at or after midnight * Fixed bug in `hoursInDay` property getter * FIxed docs for `isTimeZoneOffsetTransition` property * Added DST-focused tests for all three properties * Also added tests for `toLocalDateTime` methods on other types
This arises from a need identified in feedback to have a more ergonomic way to get a Temporal.DateTime with midnight on a certain date. Closes: #737
* Per tc39#737, adds property to get first valid time at or after midnight * Fixed bug in `hoursInDay` property getter * FIxed docs for `isTimeZoneOffsetTransition` property * Added DST-focused tests for all three properties * Also added tests for `toLocalDateTime` methods on other types
* Per tc39#737, adds property to get first valid time at or after midnight * Fixed bug in `hoursInDay` property getter * FIxed docs for `isTimeZoneOffsetTransition` property * Added DST-focused tests for all three properties * Also added tests for `toLocalDateTime` methods on other types
* Per tc39#737, adds property to get first valid time at or after midnight * Fixed bug in `hoursInDay` property getter * FIxed docs for `isTimeZoneOffsetTransition` property * Added DST-focused tests for all three properties * Also added tests for `toLocalDateTime` methods on other types
* Per tc39#737, adds property to get first valid time at or after midnight * Fixed bug in `hoursInDay` property getter * FIxed docs for `isTimeZoneOffsetTransition` property * Added DST-focused tests for all three properties * Also added tests for `toLocalDateTime` methods on other types
* Per tc39#737, adds property to get first valid time at or after midnight * Fixed bug in `hoursInDay` property getter * FIxed docs for `isTimeZoneOffsetTransition` property * Added DST-focused tests for all three properties * Also added tests for `toLocalDateTime` methods on other types
* Per tc39#737, adds property to get first valid time at or after midnight * Fixed bug in `hoursInDay` property getter * FIxed docs for `isTimeZoneOffsetTransition` property * Added DST-focused tests for all three properties * Also added tests for `toLocalDateTime` methods on other types
* Per tc39#737, adds property to get first valid time at or after midnight * Fixed bug in `hoursInDay` property getter * FIxed docs for `isTimeZoneOffsetTransition` property * Added DST-focused tests for all three properties * Also added tests for `toLocalDateTime` methods on other types
* Per tc39#737, adds property to get first valid time at or after midnight * Fixed bug in `hoursInDay` property getter * FIxed docs for `isTimeZoneOffsetTransition` property * Added DST-focused tests for all three properties * Also added tests for `toLocalDateTime` methods on other types
* Per tc39#737, adds property to get first valid time at or after midnight * Fixed bug in `hoursInDay` property getter * FIxed docs for `isTimeZoneOffsetTransition` property * Added DST-focused tests for all three properties * Also added tests for `toLocalDateTime` methods on other types
* Per tc39#737, adds property to get first valid time at or after midnight * Fixed bug in `hoursInDay` property getter * FIxed docs for `isTimeZoneOffsetTransition` property * Added DST-focused tests for all three properties * Also added tests for `toLocalDateTime` methods on other types
* Per tc39#737, adds property to get first valid time at or after midnight * Fixed bug in `hoursInDay` property getter * FIxed docs for `isTimeZoneOffsetTransition` property * Added DST-focused tests for all three properties * Also added tests for `toLocalDateTime` methods on other types
* Per tc39#737, adds property to get first valid time at or after midnight * Fixed bug in `hoursInDay` property getter * FIxed docs for `isTimeZoneOffsetTransition` property * Added DST-focused tests for all three properties * Also added tests for `toLocalDateTime` methods on other types
* Per tc39#737, adds property to get first valid time at or after midnight * Fixed bug in `hoursInDay` property getter * FIxed docs for `isTimeZoneOffsetTransition` property * Added DST-focused tests for all three properties * Also added tests for `toLocalDateTime` methods on other types
From #729 (comment): (Splitting this feedback out from #729 which is focused on several topics. )
FWIW, I've also been bothered by the non-DRY of
Temporal.Time.from('00:00')
, given how common of a use-case it is to need a midnight time.Should the
Time
parameter ofDate.prototype.toDateTime
be optional, where an omitted parameter means "midnight"?Should midnight be a constant, e.g.
Temporal.Time.MIDNIGHT
? This isn't many fewer characters thanTemporal.Time.from('00:00')
but it's more discoverable and is much less typing in an IDE due to autocomplete.The text was updated successfully, but these errors were encountered: