Skip to content

Commit

Permalink
[results] should fix wrong race hour countdown
Browse files Browse the repository at this point in the history
  • Loading branch information
BrightDV committed Jul 16, 2024
1 parent 1fed6a8 commit ab4b394
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/Screens/race_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1438,15 +1438,15 @@ class _SessionCountdownTimerState extends State<SessionCountdownTimer> {
return to.difference(from).inSeconds;
}

// time to race in seconds
timeToRace = timeBetween(
DateTime.now(),
raceFullDateParsed,
);
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,
Expand Down
10 changes: 6 additions & 4 deletions lib/api/formula1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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'],
Expand All @@ -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();

Expand All @@ -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'],
Expand Down

0 comments on commit ab4b394

Please sign in to comment.