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

Side by Side Diff: lib/compiler/implementation/lib/js_helper.dart

Issue 10413031: Reapply "Add support for timezone offset and timezone name." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 8 years, 7 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
« no previous file with comments | « frog/lib/date_implementation.dart ('k') | lib/compiler/implementation/lib/mockimpl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4
5 #library('js_helper'); 5 #library('js_helper');
6 6
7 #import('coreimpl.dart'); 7 #import('coreimpl.dart');
8 8
9 #source('constant_map.dart'); 9 #source('constant_map.dart');
10 #source('native_helper.dart'); 10 #source('native_helper.dart');
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 static num dateNow() => JS('num', @'Date.now()'); 322 static num dateNow() => JS('num', @'Date.now()');
323 323
324 static String stringFromCharCodes(charCodes) { 324 static String stringFromCharCodes(charCodes) {
325 for (var i in charCodes) { 325 for (var i in charCodes) {
326 if (i is !int) throw new IllegalArgumentException(i); 326 if (i is !int) throw new IllegalArgumentException(i);
327 } 327 }
328 return JS('String', @'String.fromCharCode.apply(#, #)', null, charCodes); 328 return JS('String', @'String.fromCharCode.apply(#, #)', null, charCodes);
329 } 329 }
330 330
331 static String getTimeZoneName(receiver) {
332 // When calling toString on a Date it will emit the timezone in parenthesis.
333 // Example: "Wed May 16 2012 21:13:00 GMT+0200 (CEST)".
334 // We extract this name using a regexp.
335 var d = lazyAsJsDate(receiver);
336 return JS('String', @'/\((.*)\)/.exec(#.toString())[1]', d);
337 }
338
339 static int getTimeZoneOffsetInMinutes(receiver) {
340 // Note that JS and Dart disagree on the sign of the offset.
341 return -JS('int', @'#.getTimezoneOffset()', lazyAsJsDate(receiver));
342 }
343
331 static valueFromDecomposedDate(years, month, day, hours, minutes, seconds, 344 static valueFromDecomposedDate(years, month, day, hours, minutes, seconds,
332 milliseconds, isUtc) { 345 milliseconds, isUtc) {
333 checkInt(years); 346 checkInt(years);
334 checkInt(month); 347 checkInt(month);
335 if (month < 1 || 12 < month) throw new IllegalArgumentException(month); 348 if (month < 1 || 12 < month) throw new IllegalArgumentException(month);
336 checkInt(day); 349 checkInt(day);
337 if (day < 1 || 31 < day) throw new IllegalArgumentException(day); 350 if (day < 1 || 31 < day) throw new IllegalArgumentException(day);
338 checkInt(hours); 351 checkInt(hours);
339 if (hours < 0 || 24 < hours) throw new IllegalArgumentException(hours); 352 if (hours < 0 || 24 < hours) throw new IllegalArgumentException(hours);
340 checkInt(minutes); 353 checkInt(minutes);
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 if (JS('bool', '!!#[#]', value, property)) return value; 903 if (JS('bool', '!!#[#]', value, property)) return value;
891 propertyTypeError(value, property); 904 propertyTypeError(value, property);
892 } 905 }
893 906
894 listSuperNativeTypeCheck(value, property) { 907 listSuperNativeTypeCheck(value, property) {
895 if (value === null) return value; 908 if (value === null) return value;
896 if (value is List) return value; 909 if (value is List) return value;
897 if (JS('bool', '#[#]()', value, property)) return value; 910 if (JS('bool', '#[#]()', value, property)) return value;
898 propertyTypeError(value, property); 911 propertyTypeError(value, property);
899 } 912 }
OLDNEW
« no previous file with comments | « frog/lib/date_implementation.dart ('k') | lib/compiler/implementation/lib/mockimpl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698