Skip to content

Commit 69fd2da

Browse files
committed
fix(notification): should fix timezone this time
1 parent 9302275 commit 69fd2da

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/api/race_components.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,20 @@ class RacesList extends StatelessWidget {
328328
return DateTime.now().millisecondsSinceEpoch.remainder(100000);
329329
}
330330

331+
// From https://stackoverflow.com/a/58711821
332+
String formattedTimeZoneOffset(DateTime time) {
333+
String twoDigits(int n) {
334+
if (n >= 10) return '$n';
335+
return '0$n';
336+
}
337+
338+
final duration = time.timeZoneOffset,
339+
hours = duration.inHours,
340+
minutes = duration.inMinutes.remainder(60).abs().toInt();
341+
342+
return '${hours > 0 ? '+' : '-'}${twoDigits(hours.abs())}:${twoDigits(minutes)}';
343+
}
344+
331345
Future<void> scheduledNotification(String meetingId) async {
332346
List<NotificationModel> notifications =
333347
await AwesomeNotifications().listScheduledNotifications();
@@ -363,7 +377,7 @@ class RacesList extends StatelessWidget {
363377
hour: sessionDate.hour,
364378
day: sessionDate.day,
365379
month: sessionDate.month,
366-
timeZone: 'GMT${session['gmtOffset']}',
380+
timeZone: 'GMT${formattedTimeZoneOffset(DateTime.now())}',
367381
),
368382
);
369383
}

0 commit comments

Comments
 (0)