diff --git a/lib/db/box_log.dart b/lib/db/box_log.dart index 4b6a557..d7cad02 100644 --- a/lib/db/box_log.dart +++ b/lib/db/box_log.dart @@ -21,6 +21,6 @@ class Log { {this.id = 0, DateTime? date, this.uploaded = 0}) : date = date ?? DateTime.now(); - String get dateFormat => DateFormat('dd/MM/yyyy hh:mm:ss').format(date); - String get dateEnFormat => DateFormat('yyyyMMdd hh:mm:ss').format(date); + String get dateFormat => DateFormat('dd/MM/yyyy HH:mm:ss').format(date); + String get dateEnFormat => DateFormat('yyyyMMdd HH:mm:ss').format(date); } diff --git a/lib/db/box_visit_photo.dart b/lib/db/box_visit_photo.dart index b633f22..1d22d8e 100644 --- a/lib/db/box_visit_photo.dart +++ b/lib/db/box_visit_photo.dart @@ -48,7 +48,7 @@ class VisitPhoto { return image_name; } - String get dateFormat => DateFormat('dd.MM.yyyy hh:mm:ss').format(date_photo); + String get dateFormat => DateFormat('dd.MM.yyyy HH:mm:ss').format(date_photo); VisitPhoto copyWith({ int? id, diff --git a/lib/main.dart b/lib/main.dart index 958cad1..f7e743f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -24,6 +24,18 @@ late ObjectBox objectbox; final EventBus eventBus = EventBus(); +String getCurrentTimeZone(DateTime dateTime) { + Duration offset = dateTime.timeZoneOffset; + int offsetHours = offset.inHours; + int offsetMinutes = offset.inMinutes.remainder(60); + + String offsetSign = offset.isNegative ? '-' : '+'; + String timeZone = + '$offsetSign${offsetHours.abs().toString().padLeft(2, '0')}:${offsetMinutes.abs().toString().padLeft(2, '0')}'; + + return timeZone; +} + Future main() async { // This is required so ObjectBox can get the application directory // to store the database in. @@ -49,6 +61,9 @@ Future main() async { /// initialize tracker plausible analytics await PlausibleUtil.initializePlausible(window.physicalSize.width); + // initialize time zone current device + SharedPrefs().timeZone = getCurrentTimeZone(DateTime.now()); + // url MP4 SharedPrefs().urlMP4 = 'https://mp4.ikksgroup.com/MobilePortal4/index.html#ajax/dashboard.html'; diff --git a/lib/service/shared_prefs.dart b/lib/service/shared_prefs.dart index 3383ef5..e537bf8 100644 --- a/lib/service/shared_prefs.dart +++ b/lib/service/shared_prefs.dart @@ -175,4 +175,11 @@ class SharedPrefs { set photoSound(bool value) { _sharedPrefs.setBool('key_photo_sound', value); } + + /// get/set user time zone + String get timeZone => _sharedPrefs.getString('key_timeZone') ?? ""; + + set timeZone(String value) { + _sharedPrefs.setString('key_timeZone', value); + } }