Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(973)

Unified Diff: samples/total/client/DateTimeUtils.dart

Issue 10544109: Round days-computation to get rid of daylight-savings differences. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/total/client/DateTimeUtils.dart
diff --git a/samples/total/client/DateTimeUtils.dart b/samples/total/client/DateTimeUtils.dart
index b44014d06a557dffeed074e2cd68e07d0f705915..bbbc37f1e88356764727016aa71e25ccac38b118 100644
--- a/samples/total/client/DateTimeUtils.dart
+++ b/samples/total/client/DateTimeUtils.dart
@@ -65,8 +65,8 @@ class DateUtils {
static double now() {
Date nowDate = new Date.now();
int milliseconds = nowDate.difference(EPOCH).inMilliseconds;
- milliseconds += MILLISECONDS_PER_HOUR; // FIXME - something is one hour behind
- double days = milliseconds / MILLISECONDS_PER_DAY;
+ // We round the result to get rid of daylight saving differences.
+ double days = (milliseconds / MILLISECONDS_PER_DAY).round();
return days;
}
@@ -82,8 +82,8 @@ class DateUtils {
int thisYear = nowDate.year;
Date dateTime = new Date(thisYear, month, day, 0, 0, 0, 0);
int milliseconds = dateTime.difference(EPOCH).inMilliseconds;
- milliseconds += MILLISECONDS_PER_HOUR; // FIXME - something is one hour behind
- double days = milliseconds / MILLISECONDS_PER_DAY;
+ // We round the result to get rid of daylight saving differences.
+ double days = (milliseconds / MILLISECONDS_PER_DAY).round();
return days;
}
@@ -101,8 +101,8 @@ class DateUtils {
}
Date dateTime = new Date(year, month, day, 0, 0, 0, 0);
int milliseconds = dateTime.difference(EPOCH).inMilliseconds;
- milliseconds += MILLISECONDS_PER_HOUR; // FIXME - something is one hour behind
- double days = milliseconds / MILLISECONDS_PER_DAY;
+ // We round the result to get rid of daylight saving differences.
+ double days = (milliseconds / MILLISECONDS_PER_DAY).round();
return days;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698