_This issue was originally filed by greg...@gmail.com_
It would be helpful if there was a cross platform way to fetch the iana time zone name for the server where the dart vm is currently running.
On Unix this is stored in /etc/timezone, for example on my computer it is "Pacific/Auckland".
I don't think this is always possible to do this correctly in the browser. Probably best to leave for a library there.
Note: DateTime.now().timeZoneName returns the abbreviated time zone name, which is ambiguous (CST Austrailia, and US), and differs depending on the time of the year. i.e. timeZoneName for me is currently NZDT, but in winter is NZST.
cc @floitschG.
_Added Library-Core, Area-Library, Triaged labels._
The Flutter team I work on has a need for this. We can work around it by creating a plugin, but I would be happy to have this supported directly.
@floitschG Is there any way to escalate the priority of this? In Flutter-land, folks are talking about creating a plugin to get this information which would not be ideal as it leads to API confusion (VM or Plugin?).
Have you guys created a plugin for this yet? @alanrussian @mehmetf
@lifenautjoe I believe https://pub.dartlang.org/packages/flutter_native_timezone does this for now.
Please fix this in Dart. I really don't want to import yet another third-party plugin. Please provide usable timezone info.
I believe https://pub.dartlang.org/packages/flutter_native_timezone does this for now.
It also does not work on the web
I believe https://pub.dartlang.org/packages/flutter_native_timezone does this for now.
It also does not work on the web
does not work on macos :(
Considering this needs an implementation on the platform level (ios, android, web, ...), is the dart SDK the correct place to make this ask?
Couldn't you make this argument about a lot of existing APIs in the Dart standard libraries? I think it's a matter of whether this is useful enough to meet the threshold of residing in the Dart SDK. IMO it is since it's generally useful for date time handling and DateTime is in the Dart SDK.
@alanrussian good point. It looks like there is not a lot of traction on getting it into the standard libraries, though. This issue was opened in 2014.
I agree this should be in the SDK. It is core functionality (and is currently in dart:core
).
Dart needs to provide a better integration model than the current Flutter plugin approach when it comes to core platform fidelity. See issues like: https://github.com/dart-lang/sdk/issues/39104 where we need a way to bind dart:net
to Cronet or OkHttp on Android. Same method can be used to bind dart:time
to org.joda.Time
on Android.
This is currently wishful thinking. I don't know what such a design would look like but it appears to me that a more modular approach to core APIs is needed. Another (and perhaps the biggest) problem is finding owners to such functionality. Ideally, a platform expert needs to maintain the backend of these core APIs and make sure they work on different OS versions etc. This is where the outsourced plugin approach currently falls short.
@mit-mit @mraleph This is another example use case which better interop can provide a good solution. It is odd to create an async API just to read timezone and yet that's what apps do today.
Most helpful comment
Please fix this in Dart. I really don't want to import yet another third-party plugin. Please provide usable timezone info.