-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
New methods on DateTime (lastDayOfMonth, lastDayOfWeek, firstDayOfWeek) #48943
Comments
cc @lrhn for thoughts My initial reaction is we probably wouldn't put this in the SDK. I could imagine putting this into a utility package, but it's not a good fit for any of our existing core packages. |
We don't have a I'm not completely opposed to putting DateTime extensions in The "firstDayOfWeek" is contentious, since some people (incorrectly 😛) consider Sunday the first day of the week, even though it is obviously Monday. That suggests having separate packages that you can choose between. Maybe we should have a (Also, don't use extension DateTimeFirstLast on DateTime {
DateTime get firstDayOfWeek => DateTime.utc(year, month, day + 1 - weekday);
DateTime get lastDayOfWeek => DateTime.utc(year, month, day + 7 - weekday);
DateTime get firstDayOfMonth => DateTime.utc(year, month, 1);
DateTime get lastDayOfMonth => DateTime.utc(year, month + 1, 0);
DateTime get firstDayOfYear => DateTime.utc(year, 1, 1);
DateTime get lastDayOfYear => DateTime.utc(year, 12, 31);
} which isn't affected by the time of the |
@FMorschel you should submit a PR to the time package: https://github.com/jogboms/time.dart |
As this request is now on https://github.com/jogboms/time.dart as suggested, I'm closing this issue. |
Looking for
lastDayOfMonth
like feature, found this StackOverflow question and I really liked the way Yogesh Parwani mixed Chris Buckett and Kai Sellgren awnsers. As pointed by Juniper Belmont on Buckett's answer, I do think this could be a new feature or at least pointed on the official documentation that these values could be obtained like this.Code bellow:
The text was updated successfully, but these errors were encountered: