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 _DateImpl. | 6 // VM implementation of _DateImpl. |
7 patch class _DateImpl { | 7 patch class _DateImpl { |
8 /* patch */ _DateImpl(int year, | 8 /* patch */ _DateImpl(int year, |
9 int month, | 9 int month, |
10 int day, | 10 int day, |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 ((y.remainder(100) != 0) || (y.remainder(400) == 0)); | 176 ((y.remainder(100) != 0) || (y.remainder(400) == 0)); |
177 } | 177 } |
178 | 178 |
179 static _brokenDownDateToMillisecondsSinceEpoch( | 179 static _brokenDownDateToMillisecondsSinceEpoch( |
180 int year, int month, int day, | 180 int year, int month, int day, |
181 int hour, int minute, int second, int millisecond, | 181 int hour, int minute, int second, int millisecond, |
182 bool isUtc) { | 182 bool isUtc) { |
183 // Simplify calculations by working with zero-based month. | 183 // Simplify calculations by working with zero-based month. |
184 --month; | 184 --month; |
185 // Deal with under and overflow. | 185 // Deal with under and overflow. |
186 year += (month / 12).floor().toInt(); | 186 year += (month / 12).floor(); |
187 month = month % 12; | 187 month = month % 12; |
188 | 188 |
189 // First compute the seconds in UTC, independent of the [isUtc] flag. If | 189 // First compute the seconds in UTC, independent of the [isUtc] flag. If |
190 // necessary we will add the time-zone offset later on. | 190 // necessary we will add the time-zone offset later on. |
191 int days = day - 1; | 191 int days = day - 1; |
192 days += _DAYS_UNTIL_MONTH[_isLeapYear(year) ? 1 : 0][month]; | 192 days += _DAYS_UNTIL_MONTH[_isLeapYear(year) ? 1 : 0][month]; |
193 days += _dayFromYear(year); | 193 days += _dayFromYear(year); |
194 int millisecondsSinceEpoch = days * Duration.MILLISECONDS_PER_DAY + | 194 int millisecondsSinceEpoch = days * Duration.MILLISECONDS_PER_DAY + |
195 hour * Duration.MILLISECONDS_PER_HOUR + | 195 hour * Duration.MILLISECONDS_PER_HOUR + |
196 minute * Duration.MILLISECONDS_PER_MINUTE+ | 196 minute * Duration.MILLISECONDS_PER_MINUTE+ |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 315 |
316 static String _timeZoneNameForClampedSeconds(int secondsSinceEpoch) | 316 static String _timeZoneNameForClampedSeconds(int secondsSinceEpoch) |
317 native "DateNatives_timeZoneName"; | 317 native "DateNatives_timeZoneName"; |
318 | 318 |
319 static int _timeZoneOffsetInSecondsForClampedSeconds(int secondsSinceEpoch) | 319 static int _timeZoneOffsetInSecondsForClampedSeconds(int secondsSinceEpoch) |
320 native "DateNatives_timeZoneOffsetInSeconds"; | 320 native "DateNatives_timeZoneOffsetInSeconds"; |
321 | 321 |
322 static int _localTimeZoneAdjustmentInSeconds() | 322 static int _localTimeZoneAdjustmentInSeconds() |
323 native "DateNatives_localTimeZoneAdjustmentInSeconds"; | 323 native "DateNatives_localTimeZoneAdjustmentInSeconds"; |
324 } | 324 } |
OLD | NEW |