OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #ifndef VM_OS_H_ | 5 #ifndef VM_OS_H_ |
6 #define VM_OS_H_ | 6 #define VM_OS_H_ |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 | 9 |
10 // Forward declarations. | 10 // Forward declarations. |
11 class tm; | 11 class tm; |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 // Forward declarations. | 15 // Forward declarations. |
16 class Isolate; | 16 class Isolate; |
17 | 17 |
18 // Interface to the underlying OS platform. | 18 // Interface to the underlying OS platform. |
19 class OS { | 19 class OS { |
20 public: | 20 public: |
21 // Takes the seconds since epoch (midnight, January 1, 1970 UTC) and breaks it | |
22 // down into date and time in the UTC timezone. | |
23 // The returned year is offset by 1900. The returned month is 0-based. | |
24 // Returns true if the conversion succeeds, false otherwise. | |
25 static bool GmTime(int64_t seconds_since_epoch, tm* tm_result); | |
26 | |
27 // Takes the seconds since epoch (midnight, January 1, 1970 UTC) and breaks it | |
28 // down into date and time in the local time. | |
29 // The returned year is offset by 1900. The returned month is 0-based. | |
30 // Returns true if the conversion succeeds, false otherwise. | |
31 static bool LocalTime(int64_t seconds_since_epoch, tm* tm_result); | |
32 | |
33 // Takes the broken down date and time in UTC timezone and computes the | |
34 // seconds since epoch (midnight, January 1, 1970 UTC). | |
35 // The given year is offset by 1900. The given month is 0-based. | |
36 // Returns true if the conversion succeeds, false otherwise. | |
37 static bool MkGmTime(tm* tm, int64_t* seconds_result); | |
38 | |
39 // Takes the broken down date and time in local timezone and computes the | |
40 // seconds since epoch (midnight, January 1, 1970 UTC). | |
41 // The given year is offset by 1900. The given month is 0-based. | |
42 // Returns true if the conversion succeeds, false otherwise. | |
43 static bool MkTime(tm* tm, int64_t* seconds_result); | |
44 | |
45 // Returns the abbreviated time-zone name for the given instant. | 21 // Returns the abbreviated time-zone name for the given instant. |
46 // For example "CET" or "CEST". | 22 // For example "CET" or "CEST". |
47 static bool GetTimeZoneName(int64_t seconds_since_epoch, | 23 static const char* GetTimeZoneName(int64_t seconds_since_epoch); |
48 const char** name_result); | |
49 | 24 |
50 // Returns the difference in seconds between local time and UTC for the given | 25 // Returns the difference in seconds between local time and UTC for the given |
51 // instant. | 26 // instant. |
52 // For example 3600 for CET, and 7200 for CEST. | 27 // For example 3600 for CET, and 7200 for CEST. |
53 static bool GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch, | 28 static int GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch); |
54 int* offset_result); | 29 |
| 30 // Returns the difference in seconds between local time and UTC when no |
| 31 // daylight saving is active. |
| 32 // For example 3600 in CET and CEST. |
| 33 static int GetLocalTimeZoneAdjustmentInSeconds(); |
55 | 34 |
56 // Returns the current time in milliseconds measured | 35 // Returns the current time in milliseconds measured |
57 // from midnight January 1, 1970 UTC. | 36 // from midnight January 1, 1970 UTC. |
58 static int64_t GetCurrentTimeMillis(); | 37 static int64_t GetCurrentTimeMillis(); |
59 | 38 |
60 // Returns the current time in microseconds measured | 39 // Returns the current time in microseconds measured |
61 // from midnight January 1, 1970 UTC. | 40 // from midnight January 1, 1970 UTC. |
62 static int64_t GetCurrentTimeMicros(); | 41 static int64_t GetCurrentTimeMicros(); |
63 | 42 |
64 // Returns the activation frame alignment constraint or zero if | 43 // Returns the activation frame alignment constraint or zero if |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 static void Shutdown(); | 87 static void Shutdown(); |
109 | 88 |
110 static void Abort(); | 89 static void Abort(); |
111 | 90 |
112 static void Exit(int code); | 91 static void Exit(int code); |
113 }; | 92 }; |
114 | 93 |
115 } // namespace dart | 94 } // namespace dart |
116 | 95 |
117 #endif // VM_OS_H_ | 96 #endif // VM_OS_H_ |
OLD | NEW |