Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // Patch file for dart:core's Date class. | |
| 6 | |
| 7 patch class DateImplementation { | |
| 8 patch DateImplementation(int years, | |
| 9 [int month = 1, | |
| 10 int day = 1, | |
| 11 int hour = 0, | |
| 12 int minute = 0, | |
| 13 int second = 0, | |
| 14 int millisecond = 0, | |
| 15 bool isUtc = false]) | |
| 16 : this.isUtc = checkNull(isUtc), | |
| 17 millisecondsSinceEpoch = Primitives.valueFromDecomposedDate( | |
| 18 years, month, day, hour, minute, second, millisecond, isUtc) { | |
| 19 Primitives.lazyAsJsDate(this); | |
| 20 } | |
| 21 | |
| 22 patch DateImplementation.now() | |
| 23 : isUtc = false, | |
| 24 millisecondsSinceEpoch = Primitives.dateNow() { | |
| 25 Primitives.lazyAsJsDate(this); | |
| 26 } | |
| 27 | |
| 28 patch String get timeZoneName() { | |
| 29 if (isUtc) return "UTC"; | |
| 30 return Primitives.getTimeZoneName(this); | |
| 31 } | |
| 32 | |
| 33 patch Duration get timeZoneOffset() { | |
| 34 if (isUtc) return new Duration(0); | |
| 35 return new Duration(minutes: Primitives.getTimeZoneOffsetInMinutes(this)); | |
| 36 } | |
| 37 | |
| 38 patch int get year() => Primitives.getYear(this); | |
| 39 | |
| 40 patch int get month() => Primitives.getMonth(this); | |
| 41 | |
| 42 patch int get day() => Primitives.getDay(this); | |
| 43 | |
| 44 patch int get hour() => Primitives.getHours(this); | |
| 45 | |
| 46 patch int get minute() => Primitives.getMinutes(this); | |
| 47 | |
| 48 patch int get second() => Primitives.getSeconds(this); | |
| 49 | |
| 50 patch int get millisecond() => Primitives.getMilliseconds(this); | |
| 51 | |
| 52 patch int get weekday() { | |
| 53 // Adjust by one because JS weeks start on Sunday. | |
| 54 var day = Primitives.getWeekday(this); | |
|
floitsch
2012/08/01 09:05:01
We should be consistent: either we let the Primiti
Anders Johnsen
2012/08/01 09:15:38
Done.
| |
| 55 return (day + 6) % 7 + Date.MON; | |
| 56 } | |
| 57 } | |
| OLD | NEW |