Chromium Code Reviews| Index: runtime/lib/date_patch.dart |
| diff --git a/runtime/lib/date_patch.dart b/runtime/lib/date_patch.dart |
| index 9411bf3f0d91a079851afad8f5675304f808ba86..60dced193eb3cadff59cd497e183be93ab7eb6a0 100644 |
| --- a/runtime/lib/date_patch.dart |
| +++ b/runtime/lib/date_patch.dart |
| @@ -147,7 +147,7 @@ patch class DateTime { |
| return __parts; |
| } |
| - /* patch */ int get millisecond => _parts[_MILLISECOND_INDEX]; |
| + /* patch */ int get millisecond => __[_MILLISECOND_INDEX]; |
|
Søren Gjesse
2015/01/07 10:48:18
Where does __ come from?
Lasse Reichstein Nielsen
2015/01/07 12:01:19
Ack, bad edit.
Søren Gjesse
2015/01/07 12:03:29
Thought so :-)
|
| /* patch */ int get second => _parts[_SECOND_INDEX]; |
| @@ -200,8 +200,8 @@ patch class DateTime { |
| } |
| static bool _isLeapYear(y) { |
| - return (y.remainder(4) == 0) && |
| - ((y.remainder(100) != 0) || (y.remainder(400) == 0)); |
| + // (y % 16 == 0) matches multiples of 400, and is faster than % 400. |
| + return (y % 4 == 0) && ((y % 16 == 0) || (y % 100 != 0)); |
| } |
| /* patch */ static int _brokenDownDateToMillisecondsSinceEpoch( |
| @@ -211,17 +211,24 @@ patch class DateTime { |
| // Simplify calculations by working with zero-based month. |
| --month; |
| // Deal with under and overflow. |
| - year += (month / 12).floor(); |
| - month = month % 12; |
| + if (month >= 12) { |
| + year += month ~/ 12; |
| + month = month % 12; |
| + } else if (month < 0) { |
| + int realMonth = month % 12; |
| + year += (month - realMonth) ~/ 12; |
| + month = realMonth; |
| + } |
| // First compute the seconds in UTC, independent of the [isUtc] flag. If |
| // necessary we will add the time-zone offset later on. |
| int days = day - 1; |
| days += _DAYS_UNTIL_MONTH[_isLeapYear(year) ? 1 : 0][month]; |
| days += _dayFromYear(year); |
| - int millisecondsSinceEpoch = days * Duration.MILLISECONDS_PER_DAY + |
| - hour * Duration.MILLISECONDS_PER_HOUR + |
| - minute * Duration.MILLISECONDS_PER_MINUTE+ |
| + int millisecondsSinceEpoch = |
| + days * Duration.MILLISECONDS_PER_DAY + |
| + hour * Duration.MILLISECONDS_PER_HOUR + |
| + minute * Duration.MILLISECONDS_PER_MINUTE + |
| second * Duration.MILLISECONDS_PER_SECOND + |
| millisecond; |