-
Notifications
You must be signed in to change notification settings - Fork 147
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
yearMonth.atEndOfMonth() / date.atStartOfDay() #729
Comments
The current way would be I'll file this under "feedback", thanks! Can you say more about what the use case was where you bumped into the lack of this method? |
js-joda's
The latter bothers me more than the lack of |
FWIW, I've also been bothered by the non-DRY of Should the And/or should midnight be a frozen constant on |
FYI, #860 fixed part of this suggestion by making the time argument optional in Temporal.now.date().toDateTime(); // time defaults to 00:00 We're also discussing how to turn a Date into a LocalDateTime, e.g. Temporal.now.date().toLocalDateTime('America/Sao_Paulo'); // time defaults to start of day An advantage if we offered this method is that the time would default to "start of day" which is usually midnight but could be another time, e.g. if DST started at midnight, or if the date uses a calendar where days don't start at midnight. It's also more ergonomic than having to go from Date=>DateTime=>LocalDateTime. |
This isn't included in the revision of Temporal that's currently under review, but we can follow up for consideration in a future revision: js-temporal/proposal-temporal-v2#9 |
Hi 👋
Can we provide a function to convert a YearMonth to a Date at the end of the month? Or how do you see the user achieving this?
Similar to what Java and js-joda provide:
https://docs.oracle.com/javase/8/docs/api/java/time/YearMonth.html#atEndOfMonth--
This also reinforces the idea that to me, it's better to have
atDate
,atTime
,atDay
,atYear
functions, or maybe go withwithDate
,withTime
,withDay
,withYear
as there is already awith
function:#722 (comment)
This also avoids
toDateOnDay
,toDateInYear
namings.Or if we want to keep current namings, then it should be named
toDateAtEndOfMonth
. If using the with- approach, it would be namedwithDayAtEndOfMonth
which I think is ok.Similarly, be able to convert a date to a datetime at the start of the day.
can become this:
What is more readable and declarative?:)
Or
toDateTimeAtStartOfDay
to keep current namings. If using the with- approach, it would be namedwithTimeAtStartOfDay
.The text was updated successfully, but these errors were encountered: