| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // Dart core library. | 4 // Dart core library. |
| 5 | 5 |
| 6 // VM implementation of DateImplementation. | 6 // VM implementation of DateImplementation. |
| 7 patch class DateImplementation { | 7 patch class DateImplementation { |
| 8 /* patch */ DateImplementation(int years, | 8 /* patch */ DateImplementation(int years, |
| 9 [int month = 1, | 9 [int month = 1, |
| 10 int day = 1, | 10 int day = 1, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 int daysSince1970 = | 75 int daysSince1970 = |
| 76 _flooredDivision(_localDateInUtcMs, Duration.MILLISECONDS_PER_DAY); | 76 _flooredDivision(_localDateInUtcMs, Duration.MILLISECONDS_PER_DAY); |
| 77 // 1970-1-1 was a Thursday. | 77 // 1970-1-1 was a Thursday. |
| 78 return ((daysSince1970 + Date.THU - Date.MON) % Date.DAYS_IN_WEEK) + | 78 return ((daysSince1970 + Date.THU - Date.MON) % Date.DAYS_IN_WEEK) + |
| 79 Date.MON; | 79 Date.MON; |
| 80 } | 80 } |
| 81 | 81 |
| 82 | 82 |
| 83 /** The first list contains the days until each month in non-leap years. The | 83 /** The first list contains the days until each month in non-leap years. The |
| 84 * second list contains the days in leap years. */ | 84 * second list contains the days in leap years. */ |
| 85 static final List<List<int>> _DAYS_UNTIL_MONTH = | 85 static const List<List<int>> _DAYS_UNTIL_MONTH = |
| 86 const [const [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334], | 86 const [const [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334], |
| 87 const [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335]]; | 87 const [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335]]; |
| 88 | 88 |
| 89 // Returns the UTC year, month and day for the corresponding | 89 // Returns the UTC year, month and day for the corresponding |
| 90 // [millisecondsSinceEpoch]. | 90 // [millisecondsSinceEpoch]. |
| 91 // Code is adapted from V8. | 91 // Code is adapted from V8. |
| 92 static List<int> _decomposeIntoYearMonthDay(int millisecondsSinceEpoch) { | 92 static List<int> _decomposeIntoYearMonthDay(int millisecondsSinceEpoch) { |
| 93 // TODO(floitsch): cache result. | 93 // TODO(floitsch): cache result. |
| 94 final int DAYS_IN_4_YEARS = 4 * 365 + 1; | 94 final int DAYS_IN_4_YEARS = 4 * 365 + 1; |
| 95 final int DAYS_IN_100_YEARS = 25 * DAYS_IN_4_YEARS - 1; | 95 final int DAYS_IN_100_YEARS = 25 * DAYS_IN_4_YEARS - 1; |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 | 318 |
| 319 static String _timeZoneNameForClampedSeconds(int secondsSinceEpoch) | 319 static String _timeZoneNameForClampedSeconds(int secondsSinceEpoch) |
| 320 native "DateNatives_timeZoneName"; | 320 native "DateNatives_timeZoneName"; |
| 321 | 321 |
| 322 static int _timeZoneOffsetInSecondsForClampedSeconds(int secondsSinceEpoch) | 322 static int _timeZoneOffsetInSecondsForClampedSeconds(int secondsSinceEpoch) |
| 323 native "DateNatives_timeZoneOffsetInSeconds"; | 323 native "DateNatives_timeZoneOffsetInSeconds"; |
| 324 | 324 |
| 325 static int _localTimeZoneAdjustmentInSeconds() | 325 static int _localTimeZoneAdjustmentInSeconds() |
| 326 native "DateNatives_localTimeZoneAdjustmentInSeconds"; | 326 native "DateNatives_localTimeZoneAdjustmentInSeconds"; |
| 327 } | 327 } |
| OLD | NEW |