diff --git a/client/lib/api/who_date_format.dart b/client/lib/api/who_date_format.dart new file mode 100644 index 0000000000..e921012309 --- /dev/null +++ b/client/lib/api/who_date_format.dart @@ -0,0 +1,9 @@ +import 'package:intl/intl.dart'; + +extension WHOFormat on DateTime { + String get whoFormat => DateFormat.yMMMd().format( + // Timestamps are for midnight so the day it applies to is ambiguous. + // Sets date to UTC to match the WHO Dashboard: http://covid19.who.int + toUtc() + ); +} diff --git a/client/lib/components/recent_numbers_graph.dart b/client/lib/components/recent_numbers_graph.dart index 5e8e8035f0..f6ee19e74b 100644 --- a/client/lib/components/recent_numbers_graph.dart +++ b/client/lib/components/recent_numbers_graph.dart @@ -6,6 +6,7 @@ import 'package:who_app/components/themed_text.dart'; import 'package:who_app/constants.dart'; import 'package:who_app/pages/main_pages/recent_numbers.dart'; import 'package:who_app/proto/api/who/who.pb.dart'; +import 'package:who_app/api/who_date_format.dart'; const double padding = 30; const Duration defaultSwapDuration = Duration( @@ -75,7 +76,7 @@ class _RecentNumbersBarGraphState extends State { final date = DateTime.fromMillisecondsSinceEpoch( widget.timeseries[index].epochMsec.toInt()); // Abbr to fit on single line: e.g. "Oct 18, 2020" - final formattedDate = DateFormat.yMMMd().format(date); + final formattedDate = date.whoFormat; final formattedCount = NumberFormat().format(barRodData.y); @@ -269,11 +270,9 @@ class _RecentNumbersGraphState extends State { if (epochsMilliseconds == null) { return ''; } else { - return DateFormat.MMMd().format( - DateTime.fromMillisecondsSinceEpoch( - epochsMilliseconds, - ), - ); + return DateTime.fromMillisecondsSinceEpoch( + epochsMilliseconds, + ).whoFormat; } }