OLD | NEW |
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" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 bool succeeded = BrokenDownToSecondsSinceEpoch(broken_down, | 132 bool succeeded = BrokenDownToSecondsSinceEpoch(broken_down, |
133 dart_is_utc.value(), | 133 dart_is_utc.value(), |
134 &value); | 134 &value); |
135 if (!succeeded) { | 135 if (!succeeded) { |
136 UNIMPLEMENTED(); | 136 UNIMPLEMENTED(); |
137 } | 137 } |
138 arguments->SetReturn(Integer::Handle(Integer::New(value))); | 138 arguments->SetReturn(Integer::Handle(Integer::New(value))); |
139 } | 139 } |
140 | 140 |
141 | 141 |
142 DEFINE_NATIVE_ENTRY(DateNatives_timeZoneName, 1) { | |
143 GET_NATIVE_ARGUMENT(Integer, dart_seconds, arguments->At(0)); | |
144 int64_t seconds = dart_seconds.AsInt64Value(); | |
145 const char* name; | |
146 bool succeeded = OS::GetTimeZoneName(seconds, &name); | |
147 if (!succeeded) { | |
148 UNIMPLEMENTED(); | |
149 } | |
150 const String& dart_name = String::Handle(String::New(name)); | |
151 arguments->SetReturn(dart_name); | |
152 } | |
153 | |
154 | |
155 DEFINE_NATIVE_ENTRY(DateNatives_timeZoneOffsetInSeconds, 1) { | |
156 GET_NATIVE_ARGUMENT(Integer, dart_seconds, arguments->At(0)); | |
157 int64_t seconds = dart_seconds.AsInt64Value(); | |
158 int offset; | |
159 bool succeeded = OS::GetTimeZoneOffsetInSeconds(seconds, &offset); | |
160 if (!succeeded) { | |
161 UNIMPLEMENTED(); | |
162 } | |
163 const Integer& dart_offset = Integer::Handle(Integer::New(offset)); | |
164 arguments->SetReturn(dart_offset); | |
165 } | |
166 | |
167 | |
168 DEFINE_NATIVE_ENTRY(DateNatives_currentTimeMillis, 0) { | 142 DEFINE_NATIVE_ENTRY(DateNatives_currentTimeMillis, 0) { |
169 const Integer& time = Integer::Handle( | 143 const Integer& time = Integer::Handle( |
170 Integer::New(OS::GetCurrentTimeMillis())); | 144 Integer::New(OS::GetCurrentTimeMillis())); |
171 arguments->SetReturn(time); | 145 arguments->SetReturn(time); |
172 } | 146 } |
173 | 147 |
174 | 148 |
175 DEFINE_NATIVE_ENTRY(DateNatives_getYear, 2) { | 149 DEFINE_NATIVE_ENTRY(DateNatives_getYear, 2) { |
176 GET_NATIVE_ARGUMENT(Integer, dart_seconds, arguments->At(0)); | 150 GET_NATIVE_ARGUMENT(Integer, dart_seconds, arguments->At(0)); |
177 GET_NATIVE_ARGUMENT(Bool, dart_is_utc, arguments->At(1)); | 151 GET_NATIVE_ARGUMENT(Bool, dart_is_utc, arguments->At(1)); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 bool succeeded = | 223 bool succeeded = |
250 BreakDownSecondsSinceEpoch(dart_seconds, dart_is_utc, &broken_down); | 224 BreakDownSecondsSinceEpoch(dart_seconds, dart_is_utc, &broken_down); |
251 if (!succeeded) { | 225 if (!succeeded) { |
252 UNIMPLEMENTED(); | 226 UNIMPLEMENTED(); |
253 } | 227 } |
254 const Smi& result = Smi::Handle(Smi::New(broken_down.seconds)); | 228 const Smi& result = Smi::Handle(Smi::New(broken_down.seconds)); |
255 arguments->SetReturn(result); | 229 arguments->SetReturn(result); |
256 } | 230 } |
257 | 231 |
258 } // namespace dart | 232 } // namespace dart |
OLD | NEW |