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
3// BSD-style license that can be found in the LICENSE file.
4
5#include <time.h>
6
7#include "vm/bootstrap_natives.h"
8
9#include "vm/native_entry.h"
10#include "vm/object.h"
11#include "vm/os.h"
12
13namespace dart {
14
15static int64_t kMaxAllowedSeconds = kMaxInt32;
16
17DEFINE_NATIVE_ENTRY(DateTime_timeZoneName, 0, 1) {
18 GET_NON_NULL_NATIVE_ARGUMENT(Integer, dart_seconds,
19 arguments->NativeArgAt(0));
20 int64_t seconds = dart_seconds.AsInt64Value();
21 if (llabs(x: seconds) > kMaxAllowedSeconds) {
22 Exceptions::ThrowArgumentError(arg: dart_seconds);
23 }
24 const char* name = OS::GetTimeZoneName(seconds_since_epoch: seconds);
25 return String::New(cstr: name);
26}
27
28DEFINE_NATIVE_ENTRY(DateTime_timeZoneOffsetInSeconds, 0, 1) {
29 GET_NON_NULL_NATIVE_ARGUMENT(Integer, dart_seconds,
30 arguments->NativeArgAt(0));
31 int64_t seconds = dart_seconds.AsInt64Value();
32 if (llabs(x: seconds) > kMaxAllowedSeconds) {
33 Exceptions::ThrowArgumentError(arg: dart_seconds);
34 }
35 int offset = OS::GetTimeZoneOffsetInSeconds(seconds_since_epoch: seconds);
36 return Integer::New(value: offset);
37}
38
39DEFINE_NATIVE_ENTRY(DateTime_currentTimeMicros, 0, 0) {
40 return Integer::New(value: OS::GetCurrentTimeMicros());
41}
42
43} // namespace dart
44

source code of flutter_engine/third_party/dart/runtime/lib/date.cc