initializeTimeZone function
Initialize Time Zone database.
Throws TimeZoneInitException when something is worng.
import 'package:pg_timezone/standalone.dart';
initializeTimeZone().then(() {
final detroit = getLocation('America/Detroit');
final detroitNow = TZDateTime.now(detroit);
});
Implementation
Future<void> initializeTimeZone([String? path]) {
path ??= tzDataDefaultPath;
return _loadAsBytes(path).then((rawData) {
initializeDatabase(rawData);
}).catchError((dynamic e) {
throw TimeZoneInitException(e.toString());
});
}