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
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,
);
}
The text was updated successfully, but these errors were encountered:
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?
The text was updated successfully, but these errors were encountered: