Skip to content

Commit f5eb86c

Browse files
authored
Merge pull request #273 from mgoodness/fix-sac-date-format
Fix SAC date format
2 parents dc29e37 + 05da8ab commit f5eb86c

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

lib/features/statistics/data/repositories/statistics_repository.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ class RankingItem {
2525
final int count;
2626
final double? value;
2727
final String? subtitle;
28+
final DateTime? date;
2829

2930
RankingItem({
3031
required this.id,
3132
required this.name,
3233
required this.count,
3334
this.value,
3435
this.subtitle,
36+
this.date,
3537
});
3638
}
3739

@@ -234,15 +236,15 @@ class StatisticsRepository {
234236

235237
RankingItem mapRow(dynamic row) {
236238
final dateMs = row.read<int>('dive_date_time');
237-
final date = DateTime.fromMillisecondsSinceEpoch(dateMs);
239+
final date = DateTime.fromMillisecondsSinceEpoch(dateMs, isUtc: true);
238240
final diveNum = row.read<int?>('dive_number');
239241
final siteName = row.read<String?>('site_name');
240242
return RankingItem(
241243
id: row.read<String>('id'),
242244
name: siteName ?? 'Dive #${diveNum ?? "?"}',
243245
count: 0,
244246
value: row.read<double>('sac'),
245-
subtitle: '${date.day}/${date.month}/${date.year}',
247+
date: date,
246248
);
247249
}
248250

@@ -286,15 +288,15 @@ class StatisticsRepository {
286288

287289
RankingItem mapRow(dynamic row) {
288290
final dateMs = row.read<int>('dive_date_time');
289-
final date = DateTime.fromMillisecondsSinceEpoch(dateMs);
291+
final date = DateTime.fromMillisecondsSinceEpoch(dateMs, isUtc: true);
290292
final diveNum = row.read<int?>('dive_number');
291293
final siteName = row.read<String?>('site_name');
292294
return RankingItem(
293295
id: row.read<String>('id'),
294296
name: siteName ?? 'Dive #${diveNum ?? "?"}',
295297
count: 0,
296298
value: row.read<double>('sac'),
297-
subtitle: '${date.day}/${date.month}/${date.year}',
299+
date: date,
298300
);
299301
}
300302

lib/features/statistics/presentation/pages/statistics_gas_page.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ class StatisticsGasPage extends ConsumerWidget {
256256
ValueRankingCard(
257257
title: context.l10n.statistics_gas_sacRecords_best,
258258
value: formatSacRecord(records.best!.value),
259-
subtitle: records.best!.subtitle,
259+
subtitle: units.formatDate(records.best!.date),
260260
icon: Icons.emoji_events,
261261
iconColor: Colors.green,
262262
onTap: () => context.push('/dives/${records.best!.id}'),
@@ -267,7 +267,7 @@ class StatisticsGasPage extends ConsumerWidget {
267267
ValueRankingCard(
268268
title: context.l10n.statistics_gas_sacRecords_highest,
269269
value: formatSacRecord(records.worst!.value),
270-
subtitle: records.worst!.subtitle,
270+
subtitle: units.formatDate(records.worst!.date),
271271
icon: Icons.speed,
272272
iconColor: Colors.orange,
273273
onTap: () => context.push('/dives/${records.worst!.id}'),

0 commit comments

Comments
 (0)