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

Unified Diff: lib/compiler/implementation/lib/js_helper.dart

Issue 11226003: Make sure that parts of a date are returned as ints. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add comment. Created 8 years, 2 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
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/lib/js_helper.dart
diff --git a/lib/compiler/implementation/lib/js_helper.dart b/lib/compiler/implementation/lib/js_helper.dart
index 80d93d3d4b016b31f0727a0c8f4f33e1d654d32c..d2e58104064674e0ccd5f24ee86264d89bfd65d5 100644
--- a/lib/compiler/implementation/lib/js_helper.dart
+++ b/lib/compiler/implementation/lib/js_helper.dart
@@ -539,50 +539,50 @@ class Primitives {
static getYear(receiver) {
return (receiver.isUtc)
- ? JS('int', r'#.getUTCFullYear()', lazyAsJsDate(receiver))
- : JS('int', r'#.getFullYear()', lazyAsJsDate(receiver));
+ ? JS('int', r'(#.getUTCFullYear() + 0)', lazyAsJsDate(receiver))
Lasse Reichstein Nielsen 2012/10/19 11:23:41 Is this optimal - we could do '... | 0' instead an
kasperl 2012/10/19 11:26:26 I prefer the + 0 because it seems safer, but it de
ngeoffray 2012/10/25 15:14:33 This looks very magic. A comment or helper would b
ngeoffray 2012/10/26 11:42:44 Scratch that comment, I just saw: https://coderevi
+ : JS('int', r'(#.getFullYear() + 0)', lazyAsJsDate(receiver));
}
static getMonth(receiver) {
return (receiver.isUtc)
- ? JS('int', r'#.getUTCMonth()', lazyAsJsDate(receiver)) + 1
- : JS('int', r'#.getMonth()', lazyAsJsDate(receiver)) + 1;
+ ? JS('int', r'#.getUTCMonth() + 1', lazyAsJsDate(receiver))
+ : JS('int', r'#.getMonth() + 1', lazyAsJsDate(receiver));
}
static getDay(receiver) {
return (receiver.isUtc)
- ? JS('int', r'#.getUTCDate()', lazyAsJsDate(receiver))
- : JS('int', r'#.getDate()', lazyAsJsDate(receiver));
+ ? JS('int', r'(#.getUTCDate() + 0)', lazyAsJsDate(receiver))
+ : JS('int', r'(#.getDate() + 0)', lazyAsJsDate(receiver));
}
static getHours(receiver) {
return (receiver.isUtc)
- ? JS('int', r'#.getUTCHours()', lazyAsJsDate(receiver))
- : JS('int', r'#.getHours()', lazyAsJsDate(receiver));
+ ? JS('int', r'(#.getUTCHours() + 0)', lazyAsJsDate(receiver))
+ : JS('int', r'(#.getHours() + 0)', lazyAsJsDate(receiver));
}
static getMinutes(receiver) {
return (receiver.isUtc)
- ? JS('int', r'#.getUTCMinutes()', lazyAsJsDate(receiver))
- : JS('int', r'#.getMinutes()', lazyAsJsDate(receiver));
+ ? JS('int', r'(#.getUTCMinutes() + 0)', lazyAsJsDate(receiver))
+ : JS('int', r'(#.getMinutes() + 0)', lazyAsJsDate(receiver));
}
static getSeconds(receiver) {
return (receiver.isUtc)
- ? JS('int', r'#.getUTCSeconds()', lazyAsJsDate(receiver))
- : JS('int', r'#.getSeconds()', lazyAsJsDate(receiver));
+ ? JS('int', r'(#.getUTCSeconds() + 0)', lazyAsJsDate(receiver))
+ : JS('int', r'(#.getSeconds() + 0)', lazyAsJsDate(receiver));
}
static getMilliseconds(receiver) {
return (receiver.isUtc)
- ? JS('int', r'#.getUTCMilliseconds()', lazyAsJsDate(receiver))
- : JS('int', r'#.getMilliseconds()', lazyAsJsDate(receiver));
+ ? JS('int', r'(#.getUTCMilliseconds() + 0)', lazyAsJsDate(receiver))
+ : JS('int', r'(#.getMilliseconds() + 0)', lazyAsJsDate(receiver));
}
static getWeekday(receiver) {
int weekday = (receiver.isUtc)
- ? JS('int', r'#.getUTCDay()', lazyAsJsDate(receiver))
- : JS('int', r'#.getDay()', lazyAsJsDate(receiver));
+ ? JS('int', r'#.getUTCDay() + 0', lazyAsJsDate(receiver))
+ : JS('int', r'#.getDay() + 0', lazyAsJsDate(receiver));
// Adjust by one because JS weeks start on Sunday.
return (weekday + 6) % 7 + 1;
}
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698