From ab4b3948a55fca351ecfffff26171f13e4730f03 Mon Sep 17 00:00:00 2001 From: BrightDV <92821484+BrightDV@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:49:03 +0200 Subject: [PATCH] [results] should fix wrong race hour countdown --- lib/Screens/race_details.dart | 4 ++-- lib/api/formula1.dart | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Screens/race_details.dart b/lib/Screens/race_details.dart index 5a5e52a..6f67b96 100644 --- a/lib/Screens/race_details.dart +++ b/lib/Screens/race_details.dart @@ -1438,6 +1438,7 @@ class _SessionCountdownTimerState extends State { return to.difference(from).inSeconds; } + // time to race in seconds timeToRace = timeBetween( DateTime.now(), raceFullDateParsed, @@ -1445,8 +1446,7 @@ class _SessionCountdownTimerState extends State { days = (timeToRace / 60 / 60 / 24).round(); hours = (timeToRace / 60 / 60 - days * 24 - 1).round(); minutes = (timeToRace / 60 - days * 24 * 60 - hours * 60 + 60).round(); - seconds = - (timeToRace - days * 24 * 60 * 60 - hours * 60 * 60 - minutes * 60); + seconds = timeToRace - days * 24 * 60 * 60 - hours * 60 * 60 - minutes * 60; return Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/api/formula1.dart b/lib/api/formula1.dart index e81d4d6..bea2f44 100644 --- a/lib/api/formula1.dart +++ b/lib/api/formula1.dart @@ -721,7 +721,9 @@ class Formula1 { DateTime raceDate = DateTime.parse(element['meetingEndDate'] + element['gmtOffset']) .toLocal() - .subtract(Duration(hours: 3)); + .subtract( + Duration(hours: 2), + ); DateTime now = DateTime.now(); if (now.compareTo(raceEndDate) < 0) { @@ -740,7 +742,7 @@ class Formula1 { finalJson.indexOf(element).toString(), element['meetingKey'], element['meetingName'], - element['meetingEndDate'] + element['gmtOffset'], + raceDate.toIso8601String(), DateFormat.Hm().format(raceDate), element['meetingLocation'], element['meetingLocation'], @@ -762,7 +764,7 @@ class Formula1 { .toLocal(); DateTime raceDate = DateTime.parse(element['meetingEndDate'] + element['gmtOffset']) - .subtract(Duration(hours: 3)) + .subtract(Duration(hours: 2)) .toLocal(); DateTime now = DateTime.now(); @@ -782,7 +784,7 @@ class Formula1 { finalJson.indexOf(element).toString(), element['meetingKey'], element['meetingName'], - element['meetingEndDate'] + element['gmtOffset'], + raceDate.toIso8601String(), DateFormat.Hm().format(raceDate), element['meetingLocation'], element['meetingLocation'],