-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Move DateTime
constants for month and weekday into extension types.
#60669
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
Comments
Could work. Would probably still be available in |
Can't we implement the various units as extension types without breaking backwards compatibility? It should work if we keep the identifiers the same and the different units still implement class DateTime implements Comparable<DateTime> {
...
static const Weekday monday = Weekday(1);
static const Weekday tuesday = Weekday(2);
static const Weekday wednesday = Weekday(3);
static const Weekday thursday = Weekday(4);
static const Weekday friday = Weekday(5);
static const Weekday saturday = Weekday(6);
static const Weekday sunday = Weekday(7);
static const Month january = Month(1);
static const Month february = Month(2);
static const Month march = Month(3);
static const Month april = Month(4);
static const Month may = Month(5);
static const Month june = Month(6);
static const Month july = Month(7);
static const Month august = Month(8);
static const Month september = Month(9);
static const Month october = Month(10);
static const Month november = Month(11);
static const Month december = Month(12);
...
} Any computations which processed the units as |
The constants still need to be defined inside the But you could update the types of the existing constants also. |
The problem here is that changing the parameter type to We can make If we don't change the parameter type, and keep it as So, sadly it's not possible with the current feature-set, not without breaking far too much code. |
You are correct, I only considered usages of the constants directly. It would be very breaking to make the changes because So it would only make sense to do as @mmcdon20 originally proposed, and add the new types while keeping the original class as it is. Then new constructors, methods, etc would have to be added to |
Thats unfortunate. I think it can be made to work with any of the following, but some of these might work better than others:
|
Currently
DateTime
has the following definition:I propose that we deprecate the constants in
DateTime
and create extension types to represent theMonth
andWeekday
.The reason for this change is to better enable the upcoming
dot-shorthands
feature.The proposed change would allow us to write for example:
The text was updated successfully, but these errors were encountered: