-
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
DateFormat time zones unimplemented #10732
Comments
cc @floitschG. |
cc @alan-knight. |
It's arguably related to core, since DateTime does not store a time zone, which makes it hard to format one. Is the point of this bug that time zone should be recorded and printed, or that you'd rather just have a time zone in a format specification ignored rather than throwing an UnimplementedError? |
This comment was originally written by [email protected] My goal is to able to parse and format HTTP date strings with DateFormat. I would expect parse() to generate a correct Date object based upon the TZ in the in the source string as a UTC Date. Regarding format(), I would expect the resulting output a valid date string using GMT as the timezone. Of course ideally, DateTime would be updated to include TZ as well. |
I think DateTime.parse() might be a better API for reading a format that isn't internationalized. It appears that JavaScript's Date.parse() does read dates in this format. However, the Dart DateTime.parse doesn't use that, and reads in "a subset of ISO 8601" which isn't defined. Part of the reason timezones are unimplemented right now is that to read and correctly interpret a timezone, particularly by name, requires a great deal of data to be downloaded to a client, and we're reluctant to do that. Having just the information to read RFC822 dates wouldn't be that much, but it seems rather odd for an internationalization library to be able to read time zones, but only US ones, and only in English. |
Changed the title to: "DateFormat time zones unimplemented". |
Fwiw issue #1878 tracks the planned improvements to DateTime.parse. |
I don't think we are expecting to add more time zone names to be recognized by DateTime.parse, so "PST" is probably not going to work, even if the input was formatted as DateTime.parse expected. Added Library-Core label. |
No plans to add timezone to DateTime. Removed Area-Library, Library-Core labels. |
Removed Type-Defect label. |
If DateTime.timeZoneName works (it produces, e.g. "CDT") in a dart:html application (compiled to Javascript even), why not at least the single "z" in DateFormat? |
For one thing, people might reasonably expect that f.parse(f.format(aDate)) == aDate which would not be true if we included a time zone. |
This issue has been moved to dart-lang/i18n#330. |
This issue was originally filed by [email protected]
main() {
var df = new DateFormat("EEE, d MMM yyyy HH:mm:ss z");
var date = df.parse("Tue, 15 Nov 1994 08:12:31 PST");
print (df.format(date)); // throws exception
}
The text was updated successfully, but these errors were encountered: