Skip to content
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 #330

Open
DartBot opened this issue Jun 5, 2015 · 22 comments
Open

DateFormat time zones unimplemented #330

DartBot opened this issue Jun 5, 2015 · 22 comments
Labels
P3 A lower priority bug or feature request package:intl type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Jun 5, 2015

Originally opened as dart-lang/sdk#10732

This issue was originally filed by bordoley...@gmail.com


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
}

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/3276024?v=3" align="left" width="48" height="48"hspace="10"> Comment by anders-sandholm


cc @floitschG.
Added Area-Library, Library-Core, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/8631949?v=3" align="left" width="48" height="48"hspace="10"> Comment by floitschG


cc @alan-knight.
Removed Library-Core label.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/3476088?v=3" align="left" width="48" height="48"hspace="10"> Comment by 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?

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

This comment was originally written by bord...@gmail.com


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.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/3476088?v=3" align="left" width="48" height="48"hspace="10"> Comment by alan-knight


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.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/3476088?v=3" align="left" width="48" height="48"hspace="10"> Comment by alan-knight


Changed the title to: "DateFormat time zones unimplemented".

@DartBot DartBot added type-enhancement A request for a change that isn't a bug P3 A lower priority bug or feature request labels Jun 5, 2015
@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/8631949?v=3" align="left" width="48" height="48"hspace="10"> Comment by floitschG


Fwiw issue dart-lang/sdk#1878 tracks the planned improvements to DateTime.parse.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/4865287?v=3" align="left" width="48" height="48"hspace="10"> Comment by lrhn


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.
This seems to be something that a specialized Date parsing package should handle.


Added Library-Core label.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/1343914?v=3" align="left" width="48" height="48"hspace="10"> Comment by sgjesse


No plans to add timezone to DateTime.


Removed Area-Library, Library-Core labels.
Added Area-Pkg, Pkg-Intl labels.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/3476088?v=3" align="left" width="48" height="48"hspace="10"> Comment by alan-knight


Removed Type-Defect label.
Added Type-Enhancement label.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/8357732?v=3" align="left" width="48" height="48"hspace="10"> Comment by tlarsen4google


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?

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/3476088?v=3" align="left" width="48" height="48"hspace="10"> Comment by alan-knight


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.

@JankoLancer
Copy link

Can we implement this method? Date have timezone and timezone offset, can we return this timezone?

@j0nscalet
Copy link

While the dart team is hard at work on other higher value things...

I wanted to share this in case it's helpful to anyone. I've wrote a function that formats a DateTime that includes the time zone offset details in iso8601 format.

https://gist.github.com/j0nscalet/78a6e59d1e07b885e144e19675a04d3e

@sbeitzel
Copy link

I wonder if there's an opportunity to work with the timezone package on creating a TZDateFormat to go along with its TZDateTime.

@mosuem
Copy link
Member

mosuem commented Oct 21, 2022

Keeping this issue as a tracker for all issues around parsing and formatting time zones and time zone offsets.

@jimmyff
Copy link

jimmyff commented Dec 6, 2022

Wow can't believe this still isn't implemented in 2022 🤯

Any chance of giving this some priority dart team?

@mosuem
Copy link
Member

mosuem commented Dec 6, 2022

As stated above, the problem is mainly the large data size associated with time zones. Therefore having a separate package, such as package:timezone, is not a bad idea.

@jimmyff
Copy link

jimmyff commented Jan 12, 2023

Thanks @mosuem -I think it would be worth replacing the unimplemented error with an error that directs people to the timezone package. Otherwise you'll be getting people like me ending up here forevermore!

@mosuem mosuem transferred this issue from dart-archive/intl Apr 18, 2023
@minias
Copy link

minias commented Dec 13, 2023

Wow I still can't believe this isn't running in 2023 👎👎👎👎👎

Doesn't the darts team have a desire to solve this problem?

@ristiisa
Copy link

Doesn't the darts team have a desire to solve this problem?

They are waiting for the 10y anniversary! But yeah DateTime is the worst...

@mosuem
Copy link
Member

mosuem commented Dec 14, 2023

The Dart team cares so much about this that a member of the team is maintaining a package:timezone in his personal Github account.

The docs of package:intl should still be updated though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 A lower priority bug or feature request package:intl type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

8 participants