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

Unified Diff: lib/compiler/implementation/lib/coreimpl.dartp

Issue 10829102: Create 'unified' version of Date, with a dart2js implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update comment and group external methods. Created 8 years, 5 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
Index: lib/compiler/implementation/lib/coreimpl.dartp
diff --git a/lib/compiler/implementation/lib/coreimpl.dartp b/lib/compiler/implementation/lib/coreimpl.dartp
new file mode 100644
index 0000000000000000000000000000000000000000..86aefd5b21b8b23f652cc35891ff133ce96b6510
--- /dev/null
+++ b/lib/compiler/implementation/lib/coreimpl.dartp
@@ -0,0 +1,57 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Patch file for dart:core's Date class.
+
+patch class DateImplementation {
+ patch DateImplementation(int years,
+ [int month = 1,
+ int day = 1,
+ int hour = 0,
+ int minute = 0,
+ int second = 0,
+ int millisecond = 0,
+ bool isUtc = false])
+ : this.isUtc = checkNull(isUtc),
+ millisecondsSinceEpoch = Primitives.valueFromDecomposedDate(
+ years, month, day, hour, minute, second, millisecond, isUtc) {
+ Primitives.lazyAsJsDate(this);
+ }
+
+ patch DateImplementation.now()
+ : isUtc = false,
+ millisecondsSinceEpoch = Primitives.dateNow() {
+ Primitives.lazyAsJsDate(this);
+ }
+
+ patch String get timeZoneName() {
+ if (isUtc) return "UTC";
+ return Primitives.getTimeZoneName(this);
+ }
+
+ patch Duration get timeZoneOffset() {
+ if (isUtc) return new Duration(0);
+ return new Duration(minutes: Primitives.getTimeZoneOffsetInMinutes(this));
+ }
+
+ patch int get year() => Primitives.getYear(this);
+
+ patch int get month() => Primitives.getMonth(this);
+
+ patch int get day() => Primitives.getDay(this);
+
+ patch int get hour() => Primitives.getHours(this);
+
+ patch int get minute() => Primitives.getMinutes(this);
+
+ patch int get second() => Primitives.getSeconds(this);
+
+ patch int get millisecond() => Primitives.getMilliseconds(this);
+
+ patch int get weekday() {
+ // Adjust by one because JS weeks start on Sunday.
+ 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.
+ return (day + 6) % 7 + Date.MON;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698