From 8334a88af1f7bf66350b06708de215a646bb18f0 Mon Sep 17 00:00:00 2001 From: Sunit Shirke Date: Sat, 16 May 2020 17:41:28 +0530 Subject: [PATCH] Added Offset Minutes for display Many countries have time differences containing minutes too considering UTC time. So this update will cover every country. --- world_time_app/lib/services/world_time.dart | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/world_time_app/lib/services/world_time.dart b/world_time_app/lib/services/world_time.dart index fd1ec41..e676761 100644 --- a/world_time_app/lib/services/world_time.dart +++ b/world_time_app/lib/services/world_time.dart @@ -21,11 +21,13 @@ class WorldTime { // get properties from json String datetime = data['datetime']; - String offset = data['utc_offset'].substring(1,3); + String offset = data['utc_offset']; + String offset_h = data['utc_offset'].substring(1, 3); + String offset_m = data['utc_offset'].substring(4, 6); // create DateTime object DateTime now = DateTime.parse(datetime); - now = now.add(Duration(hours: int.parse(offset))); + now = now.add(Duration(hours: int.parse(offset_h), minutes: int.parse(offset_m))); // set the time property isDaytime = now.hour > 6 && now.hour < 20 ? true : false; @@ -38,4 +40,4 @@ class WorldTime { } -} \ No newline at end of file +}