From 1ca3704ffe123980eda8a272eebf38c8f6335d4f Mon Sep 17 00:00:00 2001 From: Benjamin Swerdlow Date: Sun, 10 Jan 2021 21:41:52 -0800 Subject: [PATCH 1/4] Match WHO Dashboard - add one day --- client/lib/components/recent_numbers_graph.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/client/lib/components/recent_numbers_graph.dart b/client/lib/components/recent_numbers_graph.dart index 1732025517..8817fdc847 100644 --- a/client/lib/components/recent_numbers_graph.dart +++ b/client/lib/components/recent_numbers_graph.dart @@ -75,7 +75,13 @@ 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 = DateFormat.yMMMd().format( + date.add( + Duration( + days: 1, + ), + ), + ); final formattedCount = NumberFormat().format(barRodData.y); @@ -272,6 +278,10 @@ class _RecentNumbersGraphState extends State { return DateFormat.yMMMd().format( DateTime.fromMillisecondsSinceEpoch( epochsMilliseconds, + ).add( + Duration( + days: 1, + ), ), ); } From c2f09932b2ed59c4a5b7e3d26ea5215325d61bbd Mon Sep 17 00:00:00 2001 From: Benjamin Swerdlow Date: Mon, 25 Jan 2021 11:01:57 -0800 Subject: [PATCH 2/4] updated --- client/lib/api/who_date_format.dart | 12 ++++++++++++ .../lib/components/recent_numbers_graph.dart | 19 ++++--------------- 2 files changed, 16 insertions(+), 15 deletions(-) create mode 100644 client/lib/api/who_date_format.dart diff --git a/client/lib/api/who_date_format.dart b/client/lib/api/who_date_format.dart new file mode 100644 index 0000000000..2c5dd01076 --- /dev/null +++ b/client/lib/api/who_date_format.dart @@ -0,0 +1,12 @@ +import 'package:intl/intl.dart'; + +extension WHOFormat on DateTime { + String get whoFormat => DateFormat.yMMMd().format( + // Timstamps are for midnight. It looks as though the WHO dashboard uses the date of when the data was reported to WHO rather than the original day. + add( + Duration( + days: 1, + ), + ), + ); +} diff --git a/client/lib/components/recent_numbers_graph.dart b/client/lib/components/recent_numbers_graph.dart index 8817fdc847..cad95582af 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,13 +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.add( - Duration( - days: 1, - ), - ), - ); + final formattedDate = date.whoFormat; final formattedCount = NumberFormat().format(barRodData.y); @@ -275,15 +270,9 @@ class _RecentNumbersGraphState extends State { if (epochsMilliseconds == null) { return ''; } else { - return DateFormat.yMMMd().format( - DateTime.fromMillisecondsSinceEpoch( + return DateTime.fromMillisecondsSinceEpoch( epochsMilliseconds, - ).add( - Duration( - days: 1, - ), - ), - ); + ).whoFormat; } } From 7ff00448144a4c0d587f636b07fd83962ff30e55 Mon Sep 17 00:00:00 2001 From: Benjamin Swerdlow Date: Mon, 25 Jan 2021 16:13:42 -0800 Subject: [PATCH 3/4] update comment --- client/lib/api/who_date_format.dart | 3 ++- client/lib/components/recent_numbers_graph.dart | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/lib/api/who_date_format.dart b/client/lib/api/who_date_format.dart index 2c5dd01076..1d8277546a 100644 --- a/client/lib/api/who_date_format.dart +++ b/client/lib/api/who_date_format.dart @@ -2,7 +2,8 @@ import 'package:intl/intl.dart'; extension WHOFormat on DateTime { String get whoFormat => DateFormat.yMMMd().format( - // Timstamps are for midnight. It looks as though the WHO dashboard uses the date of when the data was reported to WHO rather than the original day. + // Timestamps are for midnight so the day it applies to is ambiguous. + // Add 1 day to match the WHO Dashboard: http://covid19.who.int add( Duration( days: 1, diff --git a/client/lib/components/recent_numbers_graph.dart b/client/lib/components/recent_numbers_graph.dart index cad95582af..f6ee19e74b 100644 --- a/client/lib/components/recent_numbers_graph.dart +++ b/client/lib/components/recent_numbers_graph.dart @@ -270,9 +270,9 @@ class _RecentNumbersGraphState extends State { if (epochsMilliseconds == null) { return ''; } else { - return DateTime.fromMillisecondsSinceEpoch( - epochsMilliseconds, - ).whoFormat; + return DateTime.fromMillisecondsSinceEpoch( + epochsMilliseconds, + ).whoFormat; } } From 3c2ee41ad1a3fb31a63425e9ee2968f86c0d90e2 Mon Sep 17 00:00:00 2001 From: Benjamin Swerdlow Date: Sun, 7 Feb 2021 10:21:27 -0800 Subject: [PATCH 4/4] finally done --- client/lib/api/who_date_format.dart | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/client/lib/api/who_date_format.dart b/client/lib/api/who_date_format.dart index 1d8277546a..e921012309 100644 --- a/client/lib/api/who_date_format.dart +++ b/client/lib/api/who_date_format.dart @@ -3,11 +3,7 @@ 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. - // Add 1 day to match the WHO Dashboard: http://covid19.who.int - add( - Duration( - days: 1, - ), - ), + // Sets date to UTC to match the WHO Dashboard: http://covid19.who.int + toUtc() ); }