-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Provide function to get the current system timezone name #21758
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
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. |
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 needs to provide a better integration model than the current Flutter plugin approach when it comes to core platform fidelity. See issues like: #39104 where we need a way to bind 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. |
Dartlang & Flutter need this built-in for mobile. The third-party flutter_native_timezone library is unstable: CC: Flutter PM @timsneath |
Is there any way to get movement on this issue? Given that time in general in one of the most notoriously error prone concepts to deal with in programming I would argue that this is an essential part of any programming language and especially one that is aimed at client-side programming. |
Not having proper IANA timezone info in the Dart/Flutter API on all supported platforms is a big interoperability issue. Right now the Most backend languages and frameworks (e.g. Java, .Net, Rails) needs IANA name in order to to convert times with the zone offset to a proper local time in a given timezone, to present to user on the UI or when exporting data in a user-friendly format. |
Has there been any progress on this issue? I recently finished implementing detection of the platform's timezone in sugar without async or a dependency on Flutter. It works across most desktop environments + partially on certain browsers, see this. I'll be happy to PR support for desktop + web but I'm not sure exactly how to get started... or how to support Android/iOS without relying on method channels… |
The request here is for a way to get the IANA time zone name for the current local time. That's information that is not directly derivable from the current The first thing to decide is whether this is solvable at all: Can we get the information on all platforms. You can get it in the browser, using On the VM, the currently exposed time zone name is provided by asking the operating system. If not, the VM can require the embedder to provide the necessary functionality, then they can decide how to solve it. |
Fetching the IANA timezone on Windows, MacOS, Linux & web is do-able IMO. For windows, what we wound up doing was calling On another tangent, it seems like the current implementation uses For MacOS/Linux, the local IANA timezone can be fetched by resolving Besides that, it would be nice if the |
Dart's Providing the current time zone, not just the time zone offset, is a step towards locale awareness, and a reason I'd be happier to make it part of |
Perhaps I'm misunderstanding something, but all I'm suggesting is that |
Changing the current behavior is ... potentially breaking, but since the behavior is as underspecified as it is, it might just be possible. Then it becomes a matter of whether we dare do so, and whether we're able to get the necessary information on all platforms. |
I think it'd be fine to fall back to the current behavior (which I assume is supported on all platforms?) in the case that the IANA time zone isn't available. After all, if it's not there, it's just not there and there's no point in pretending. |
Are there any updates about this issue? |
This issue was originally filed by [email protected]
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.
The text was updated successfully, but these errors were encountered: