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

Side by Side Diff: compiler/lib/implementation/date_implementation.js

Issue 9702034: Removes dartc reliance on its own libraries, now can be targeted at any implementation's libraries (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: junit tests fixed Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011, 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 // Dart core library.
6
7 function date$validateValue(value) {
8 if (isNaN(value)) {
9 // TODO(floitsch): Use real exception object.
10 throw Error("Invalid Date");
11 }
12 return value;
13 }
14
15 function native_DateImplementation__valueFromDecomposed(
16 years, month, day, hours, minutes, seconds, milliseconds, isUtc) {
17 // JavaScript has 0-based months.
18 var jsMonth = month - 1;
19 var value = isUtc ?
20 Date.UTC(years, jsMonth, day,
21 hours, minutes, seconds, milliseconds) :
22 new Date(years, jsMonth, day,
23 hours, minutes, seconds, milliseconds).valueOf();
24 return date$validateValue(value);
25 }
26
27 function native_DateImplementation__valueFromString(str) {
28 return date$validateValue(Date.parse(str));
29 }
30
31 function native_DateImplementation__now() {
32 return new Date().valueOf();
33 }
34
35 function date$dateFrom(dartDate, value) {
36 // Lazily keep a JS Date stored in the dart object.
37 var date = dartDate.date;
38 if (!date) {
39 date = new Date(value);
40 dartDate.date = date;
41 }
42 return date;
43 }
44
45 function native_DateImplementation__getYear(value, isUtc) {
46 var date = date$dateFrom(this, value);
47 return isUtc ? date.getUTCFullYear() : date.getFullYear();
48 }
49
50 function native_DateImplementation__getMonth(value, isUtc) {
51 var date = date$dateFrom(this, value);
52 var jsMonth = isUtc ? date.getUTCMonth() : date.getMonth();
53 // JavaScript has 0-based months.
54 return jsMonth + 1;
55 }
56
57 function native_DateImplementation__getDay(value, isUtc) {
58 var date = date$dateFrom(this, value);
59 return isUtc ? date.getUTCDate() : date.getDate();
60 }
61
62 function native_DateImplementation__getHours(value, isUtc) {
63 var date = date$dateFrom(this, value);
64 return isUtc ? date.getUTCHours() : date.getHours();
65 }
66
67 function native_DateImplementation__getMinutes(value, isUtc) {
68 var date = date$dateFrom(this, value);
69 return isUtc ? date.getUTCMinutes() : date.getMinutes();
70 }
71
72 function native_DateImplementation__getSeconds(value, isUtc) {
73 var date = date$dateFrom(this, value);
74 return isUtc ? date.getUTCSeconds() : date.getSeconds();
75 }
76
77 function native_DateImplementation__getMilliseconds(value, isUtc) {
78 var date = date$dateFrom(this, value);
79 return isUtc ? date.getUTCMilliseconds() : date.getMilliseconds();
80 }
OLDNEW
« no previous file with comments | « compiler/lib/implementation/date_implementation.dart ('k') | compiler/lib/implementation/isolate.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698