-
Notifications
You must be signed in to change notification settings - Fork 507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Match WHO Dashboard - Add one day to stats #1921
Open
theswerd
wants to merge
6
commits into
WorldHealthOrganization:master
Choose a base branch
from
theswerd:date
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1ca3704
Match WHO Dashboard - add one day
theswerd c2f0993
updated
theswerd b04c58b
Merge branch 'master' into date
theswerd 7ff0044
update comment
theswerd ec21513
Merge branch 'date' of https://github.com/theswerd/app into date
theswerd 3c2ee41
finally done
theswerd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
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, | ||
), | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<RecentNumbersBarGraph> { | |
final date = DateTime.fromMillisecondsSinceEpoch( | ||
widget.timeseries[index].epochMsec.toInt()); | ||
// Abbr to fit on single line: e.g. "Oct 18, 2020" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move comment to the extension as the comment it common to both usages and not specific to line 78 |
||
final formattedDate = DateFormat.yMMMd().format(date); | ||
final formattedDate = date.whoFormat; | ||
|
||
final formattedCount = NumberFormat().format(barRodData.y); | ||
|
||
|
@@ -269,11 +270,9 @@ class _RecentNumbersGraphState extends State<RecentNumbersGraph> { | |
if (epochsMilliseconds == null) { | ||
return ''; | ||
} else { | ||
return DateFormat.MMMd().format( | ||
DateTime.fromMillisecondsSinceEpoch( | ||
epochsMilliseconds, | ||
), | ||
); | ||
return DateTime.fromMillisecondsSinceEpoch( | ||
epochsMilliseconds, | ||
).whoFormat; | ||
} | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you wanted to write an extension ;-) I would've included the
DateTime.fromMillisecondsSinceEpoch
step also as that's common to both usages.... and it's the msSinceEpoch that has midnight ambiguity. By the time it's converted to a date, it should be correct, so doing +1 in the format step doesn't fit so well to me.I would've just extracted a single method and not bothered with a new file. We can move it to a separate file if something else uses it. I think though that this formatting may be specific to the WHO dashboard.... no idea if it extends to the