-
Notifications
You must be signed in to change notification settings - Fork 36
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
Implement DateFormat time zone formatting #386
Comments
Duplicate of #330 We don't expect to implement those until Dart DateTime's have time zone information, and that's not planned. I wouldn't expect it unless/until JavaScript DateTime's have them. Including localized TimeZone names is a lot of data. We should probably just remove those APIs until such time as we actually provide them. |
@alan-knight Any updates on this? I am using Flutter and I cannot find any information about timezone formatting. I can only find information for localization. This is a blocker for my app. Perhaps I can temporarily hardcode |
Dart DateTime's do not have time zone information, so no, there isn't much you can do with that. I saw a reference recently to a "Time machine" package which was a port of Joda time to Dart and did include times with time zones. It's possible that would work for you. The only other obvious thing is to get time zone information from the operating system directly. |
Thanks for the pointer to https://pub.dartlang.org/packages/time_machine. I will check it out.
I am adding the offset when parsing: DateTime.parse('2018-01-01 12:00:00 +0200') Can't it be read with I'm sorry. I know that dates are extremely complex, but at the moment this is feels like half work. Dart 2 is released (:tada:), but |
I have tried Time Machine, but it is really frustrating that it is lacking (good) documentation. Either way, I think such an important feature should be supported by the Dart team. What is the reason it is not? Lack of resources or something technical?
I don't mind trying that. Do you have any pointers for me? |
https://api.dartlang.org/stable/2.3.1/dart-core/DateTime/timeZoneOffset.html
|
There is a time zone offset, it is effectively global. So DateTime instances can be either in UTC or in the local time. We can get the offset from UTC, but that does not uniquely determine the time zone, and we do not have data included for time zone names. That could be included, but it increases the data size and is not currently planned. We are more likely to delegate this to JS Intl (on web) or to ICU/operating system facilities (on mobile) going forward, rather than adding more subsets of data. |
You can still format the timezone, regardless if it's local or global. |
|
This issue is about formatting, not parsing. |
Is this different from #330? |
Not unless formatting and parsing are the same thing |
Closing in favor of #330 . |
From @ajsergeev on July 21, 2015 8:28
v,z patterns don't work because:
String formatTimeZoneId(DateTime date) {
// TODO(alanknight): implement time zone support
throw new UnimplementedError();
}
String formatTimeZone(DateTime date) {
throw new UnimplementedError();
}
String formatTimeZoneRFC(DateTime date) {
throw new UnimplementedError();
}
Copied from original issue: dart-lang/sdk#23879
The text was updated successfully, but these errors were encountered: