srawlins / timezone

Time zone database and time zone aware DateTime object for Dart.
BSD 2-Clause "Simplified" License
102 stars 54 forks source link

LocationNotFoundException (Location with the name "GMT" doesn't exist) #92

Closed armandojimenez closed 2 years ago

armandojimenez commented 3 years ago

How do I deal with this? I'm getting this on an Android Emulator

LocationNotFoundException (Location with the name "GMT" doesn't exist)

zjamshidi commented 3 years ago

Same issue

armandojimenez commented 3 years ago

Still with the same issue, I added a try/catch and assign "Accra/Africa" if an error occurs

armandojimenez commented 3 years ago

I use this, works good, but this error only occurs to me in Apple Sillicon Android Emulator

` static Future configureLocalTimeZone() async { tz.initializeTimeZones(); final String timeZoneName = await FlutterNativeTimezone.getLocalTimezone(); Logger.log('Timezone: $timeZoneName', className: '$AppConfig'); try { tz.setLocalLocation(tz.getLocation(timeZoneName)); } catch () { // Failed to get timezone or device is GMT or UTC, assign generic timezone const String fallback = 'Africa/Accra'; Logger.log('Could not get a legit timezone, setting as $fallback', className: '$AppConfig'); tz.setLocalLocation(tz.getLocation(fallback)); } }

`

Wolfteam commented 3 years ago

Hiho, I'm getting some crashes with this, in my case I get these:

Location with the name "Asia/Yangon" doesn't exist

Location with the name "America/Buenos_Aires" doesn't exist

Location with the name "Europe/Saratov" doesn't exist

Location with the name "Asia/Calcutta" doesn't exist

Location with the name "GMT" doesn't exist

Location with the name "Etc/GMT+3" doesn't exist

stvdbac commented 3 years ago

did you try using: import 'package:timezone/data/latest_all.dart' as tz; in stead of import 'package:timezone/data/latest.dart' as tz;

htunhtun-lin commented 3 years ago

did you try using: import 'package:timezone/data/latest_all.dart' as tz; in stead of import 'package:timezone/data/latest.dart' as tz;

Thank you ! It worked !

livtanong commented 2 years ago

With latest_all, "Asia/Yangon", "America/Buenos_Aires", "Etc/GMT" etc... work fine.

But "GMT" still throws for me. "Etc/GMT" seems like a good enough workaround in a try/catch.

j-dev00 commented 2 years ago

With latest_all, "Asia/Yangon", "America/Buenos_Aires", "Etc/GMT" etc... work fine.

But "GMT" still throws for me. "Etc/GMT" seems like a good enough workaround in a try/catch.

can i see your try/catch code? i am also getting "[LocationNotFoundException (Location with the name "GMT" doesn't exist)]" error on my flutter app

srawlins commented 2 years ago

Duplicate of https://github.com/srawlins/timezone/issues/80; we need to add recognized aliases, like GMT.

souza99 commented 1 year ago

i'm having this problem but. it's work :

Future _configureLocalTimeZone() async { tz.initializeTimeZones(); final String timeZone = await FlutterNativeTimezone.getLocalTimezone(); tz.setLocalLocation(tz.getLocation(timeZone)); }