You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 19, 2025. It is now read-only.
Maybe we could introduce something like this? I wanted to create an easier way to detect the current timezone so I could make a clock/countdown app that considers the timezone for alarms and/or countdowns.
Any thoughts on why this should or not be done?
import'package:timezone/timezone.dart'as tz;
import'package:timezone/data/latest.dart'as tz;
tz.LocationmyLocal() {
tz.initializeTimeZones();
final locations = tz.timeZoneDatabase.locations;
final now =DateTime.now();
final currentTimeZoneLocations = locations.values.where((location) {
return location.currentTimeZone.offset == now.timeZoneOffset.inMilliseconds;
});
return currentTimeZoneLocations.singleWhere(
(location) {
final name = location.name == now.timeZoneName;
final abbrev = location.currentTimeZone.abbreviation == now.timeZoneName;
return name || abbrev;
},
orElse: () => currentTimeZoneLocations.first,
);
}