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

Side by Side Diff: runtime/lib/date.cc

Issue 10989013: Change IllegalArgumentException to ArgumentError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated co19 test expectations. 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 unified diff | Download patch | Annotate | Revision Log
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 #include <time.h> 5 #include <time.h>
6 6
7 #include "vm/bootstrap_natives.h" 7 #include "vm/bootstrap_natives.h"
8 8
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/native_entry.h" 10 #include "vm/native_entry.h"
11 #include "vm/object.h" 11 #include "vm/object.h"
12 #include "vm/os.h" 12 #include "vm/os.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 static int32_t kMaxAllowedSeconds = 2100000000; 16 static int32_t kMaxAllowedSeconds = 2100000000;
17 17
18 DEFINE_NATIVE_ENTRY(DateNatives_timeZoneName, 1) { 18 DEFINE_NATIVE_ENTRY(DateNatives_timeZoneName, 1) {
19 GET_NATIVE_ARGUMENT(Integer, dart_seconds, arguments->At(0)); 19 GET_NATIVE_ARGUMENT(Integer, dart_seconds, arguments->At(0));
20 int64_t seconds = dart_seconds.AsInt64Value(); 20 int64_t seconds = dart_seconds.AsInt64Value();
21 if (seconds < 0 || seconds > kMaxAllowedSeconds) { 21 if (seconds < 0 || seconds > kMaxAllowedSeconds) {
22 GrowableArray<const Object*> args; 22 GrowableArray<const Object*> args;
23 args.Add(&dart_seconds); 23 args.Add(&dart_seconds);
24 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); 24 Exceptions::ThrowByType(Exceptions::kArgument, args);
25 } 25 }
26 const char* name = OS::GetTimeZoneName(seconds); 26 const char* name = OS::GetTimeZoneName(seconds);
27 return String::New(name); 27 return String::New(name);
28 } 28 }
29 29
30 30
31 DEFINE_NATIVE_ENTRY(DateNatives_timeZoneOffsetInSeconds, 1) { 31 DEFINE_NATIVE_ENTRY(DateNatives_timeZoneOffsetInSeconds, 1) {
32 GET_NATIVE_ARGUMENT(Integer, dart_seconds, arguments->At(0)); 32 GET_NATIVE_ARGUMENT(Integer, dart_seconds, arguments->At(0));
33 int64_t seconds = dart_seconds.AsInt64Value(); 33 int64_t seconds = dart_seconds.AsInt64Value();
34 if (seconds < 0 || seconds > kMaxAllowedSeconds) { 34 if (seconds < 0 || seconds > kMaxAllowedSeconds) {
35 GrowableArray<const Object*> args; 35 GrowableArray<const Object*> args;
36 args.Add(&dart_seconds); 36 args.Add(&dart_seconds);
37 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); 37 Exceptions::ThrowByType(Exceptions::kArgument, args);
38 } 38 }
39 int offset = OS::GetTimeZoneOffsetInSeconds(seconds); 39 int offset = OS::GetTimeZoneOffsetInSeconds(seconds);
40 return Integer::New(offset); 40 return Integer::New(offset);
41 } 41 }
42 42
43 43
44 DEFINE_NATIVE_ENTRY(DateNatives_localTimeZoneAdjustmentInSeconds, 0) { 44 DEFINE_NATIVE_ENTRY(DateNatives_localTimeZoneAdjustmentInSeconds, 0) {
45 int adjustment = OS::GetLocalTimeZoneAdjustmentInSeconds(); 45 int adjustment = OS::GetLocalTimeZoneAdjustmentInSeconds();
46 return Integer::New(adjustment); 46 return Integer::New(adjustment);
47 } 47 }
48 48
49 49
50 DEFINE_NATIVE_ENTRY(DateNatives_currentTimeMillis, 0) { 50 DEFINE_NATIVE_ENTRY(DateNatives_currentTimeMillis, 0) {
51 return Integer::New(OS::GetCurrentTimeMillis()); 51 return Integer::New(OS::GetCurrentTimeMillis());
52 } 52 }
53 53
54 } // namespace dart 54 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698