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

Side by Side Diff: runtime/vm/os_linux.cc

Issue 10416008: Revert "Add support for timezone offset and timezone name." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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
« no previous file with comments | « runtime/vm/os.h ('k') | runtime/vm/os_macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "vm/os.h" 5 #include "vm/os.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <limits.h> 8 #include <limits.h>
9 #include <time.h> 9 #include <time.h>
10 #include <sys/resource.h> 10 #include <sys/resource.h>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 tm->tm_wday = -1; 52 tm->tm_wday = -1;
53 time_t seconds = mktime(tm); 53 time_t seconds = mktime(tm);
54 if ((seconds == -1) && (tm->tm_wday == -1)) { 54 if ((seconds == -1) && (tm->tm_wday == -1)) {
55 return false; 55 return false;
56 } 56 }
57 *seconds_result = seconds; 57 *seconds_result = seconds;
58 return true; 58 return true;
59 } 59 }
60 60
61 61
62 bool OS::GetTimeZoneName(int64_t seconds_since_epoch,
63 const char** name_result) {
64 tm decomposed;
65 bool succeeded = LocalTime(seconds_since_epoch, &decomposed);
66 if (!succeeded) return false;
67 *name_result = decomposed.tm_zone;
68 return true;
69 }
70
71
72 bool OS::GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch,
73 int* offset_result) {
74 tm decomposed;
75 bool succeeded = LocalTime(seconds_since_epoch, &decomposed);
76 if (!succeeded) return false;
77 // Even if the offset was 24 hours it would still easily fit into 32 bits.
78 *offset_result = static_cast<int>(decomposed.tm_gmtoff);
79 return true;
80 }
81
82
83 int64_t OS::GetCurrentTimeMillis() { 62 int64_t OS::GetCurrentTimeMillis() {
84 return GetCurrentTimeMicros() / 1000; 63 return GetCurrentTimeMicros() / 1000;
85 } 64 }
86 65
87 66
88 int64_t OS::GetCurrentTimeMicros() { 67 int64_t OS::GetCurrentTimeMicros() {
89 // gettimeofday has microsecond resolution. 68 // gettimeofday has microsecond resolution.
90 struct timeval tv; 69 struct timeval tv;
91 if (gettimeofday(&tv, NULL) < 0) { 70 if (gettimeofday(&tv, NULL) < 0) {
92 UNREACHABLE(); 71 UNREACHABLE();
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 void OS::Abort() { 201 void OS::Abort() {
223 abort(); 202 abort();
224 } 203 }
225 204
226 205
227 void OS::Exit(int code) { 206 void OS::Exit(int code) {
228 exit(code); 207 exit(code);
229 } 208 }
230 209
231 } // namespace dart 210 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/os.h ('k') | runtime/vm/os_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698