94 // Called from init_globals(). |
94 // Called from init_globals(). |
95 // See Threads::create_vm() in thread.cpp, and init.cpp. |
95 // See Threads::create_vm() in thread.cpp, and init.cpp. |
96 os::init_globals(); |
96 os::init_globals(); |
97 } |
97 } |
98 |
98 |
|
99 static time_t get_timezone(const struct tm* time_struct) { |
|
100 #if defined(_ALLBSD_SOURCE) |
|
101 return time_struct->tm_gmtoff; |
|
102 #elif defined(_WINDOWS) |
|
103 long zone; |
|
104 _get_timezone(&zone); |
|
105 return static_cast<time_t>(zone); |
|
106 #else |
|
107 return timezone; |
|
108 #endif |
|
109 } |
|
110 |
99 // Fill in buffer with current local time as an ISO-8601 string. |
111 // Fill in buffer with current local time as an ISO-8601 string. |
100 // E.g., yyyy-mm-ddThh:mm:ss-zzzz. |
112 // E.g., yyyy-mm-ddThh:mm:ss-zzzz. |
101 // Returns buffer, or NULL if it failed. |
113 // Returns buffer, or NULL if it failed. |
102 // This would mostly be a call to |
114 // This would mostly be a call to |
103 // strftime(...., "%Y-%m-%d" "T" "%H:%M:%S" "%z", ....) |
115 // strftime(...., "%Y-%m-%d" "T" "%H:%M:%S" "%z", ....) |
132 struct tm time_struct; |
144 struct tm time_struct; |
133 if (localtime_pd(&seconds_since_19700101, &time_struct) == NULL) { |
145 if (localtime_pd(&seconds_since_19700101, &time_struct) == NULL) { |
134 assert(false, "Failed localtime_pd"); |
146 assert(false, "Failed localtime_pd"); |
135 return NULL; |
147 return NULL; |
136 } |
148 } |
137 #if defined(_ALLBSD_SOURCE) |
149 const time_t zone = get_timezone(&time_struct); |
138 const time_t zone = (time_t) time_struct.tm_gmtoff; |
|
139 #else |
|
140 const time_t zone = timezone; |
|
141 #endif |
|
142 |
150 |
143 // If daylight savings time is in effect, |
151 // If daylight savings time is in effect, |
144 // we are 1 hour East of our time zone |
152 // we are 1 hour East of our time zone |
145 const time_t seconds_per_minute = 60; |
153 const time_t seconds_per_minute = 60; |
146 const time_t minutes_per_hour = 60; |
154 const time_t minutes_per_hour = 60; |