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

Side by Side Diff: src/platform-win32.cc

Issue 9600018: Remove dependency on _mkgmtime to determine local timezone offset (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 9 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 60
61 61
62 int fopen_s(FILE** pFile, const char* filename, const char* mode) { 62 int fopen_s(FILE** pFile, const char* filename, const char* mode) {
63 *pFile = fopen(filename, mode); 63 *pFile = fopen(filename, mode);
64 return *pFile != NULL ? 0 : 1; 64 return *pFile != NULL ? 0 : 1;
65 } 65 }
66 66
67 67
68 #ifndef __MINGW64_VERSION_MAJOR 68 #ifndef __MINGW64_VERSION_MAJOR
69
70 // Not sure this the correct interpretation of _mkgmtime
71 time_t _mkgmtime(tm* timeptr) {
72 return mktime(timeptr);
73 }
74
75
76 #define _TRUNCATE 0 69 #define _TRUNCATE 0
77 #define STRUNCATE 80 70 #define STRUNCATE 80
78
79 #endif // __MINGW64_VERSION_MAJOR 71 #endif // __MINGW64_VERSION_MAJOR
80 72
81 73
82 int _vsnprintf_s(char* buffer, size_t sizeOfBuffer, size_t count, 74 int _vsnprintf_s(char* buffer, size_t sizeOfBuffer, size_t count,
83 const char* format, va_list argptr) { 75 const char* format, va_list argptr) {
84 ASSERT(count == _TRUNCATE); 76 ASSERT(count == _TRUNCATE);
85 return _vsnprintf(buffer, sizeOfBuffer, format, argptr); 77 return _vsnprintf(buffer, sizeOfBuffer, format, argptr);
86 } 78 }
87 79
88 80
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 double unchecked_posix_time = rounded_to_second.ToJSTime() / 1000; 501 double unchecked_posix_time = rounded_to_second.ToJSTime() / 1000;
510 if (unchecked_posix_time > INT_MAX || unchecked_posix_time < 0) { 502 if (unchecked_posix_time > INT_MAX || unchecked_posix_time < 0) {
511 return 0; 503 return 0;
512 } 504 }
513 // Because _USE_32BIT_TIME_T is defined, time_t is a 32-bit int. 505 // Because _USE_32BIT_TIME_T is defined, time_t is a 32-bit int.
514 time_t posix_time = static_cast<time_t>(unchecked_posix_time); 506 time_t posix_time = static_cast<time_t>(unchecked_posix_time);
515 507
516 // Convert to local time, as struct with fields for day, hour, year, etc. 508 // Convert to local time, as struct with fields for day, hour, year, etc.
517 tm posix_local_time_struct; 509 tm posix_local_time_struct;
518 if (localtime_s(&posix_local_time_struct, &posix_time)) return 0; 510 if (localtime_s(&posix_local_time_struct, &posix_time)) return 0;
519 // Convert local time in struct to POSIX time as if it were a UTC time.
520 time_t local_posix_time = _mkgmtime(&posix_local_time_struct);
521 Time localtime(1000.0 * local_posix_time);
522 511
523 return localtime.Diff(&rounded_to_second); 512 if (posix_local_time_struct.tm_isdst > 0)
513 return (tzinfo_.Bias + tzinfo_.DaylightBias) * -kMsPerMinute;
514 else if (posix_local_time_struct.tm_isdst == 0)
515 return (tzinfo_.Bias + tzinfo_.StandardBias) * -kMsPerMinute;
516 else
517 return tzinfo_.Bias * -kMsPerMinute;
524 } 518 }
525 519
526 520
527 // Return whether or not daylight savings time is in effect at this time. 521 // Return whether or not daylight savings time is in effect at this time.
528 bool Time::InDST() { 522 bool Time::InDST() {
529 // Initialize timezone information, if needed. 523 // Initialize timezone information, if needed.
530 TzSet(); 524 TzSet();
531 525
532 // Determine if DST is in effect at the specified time. 526 // Determine if DST is in effect at the specified time.
533 bool in_dst = false; 527 bool in_dst = false;
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 2088
2095 2089
2096 void Sampler::Stop() { 2090 void Sampler::Stop() {
2097 ASSERT(IsActive()); 2091 ASSERT(IsActive());
2098 SamplerThread::RemoveActiveSampler(this); 2092 SamplerThread::RemoveActiveSampler(this);
2099 SetActive(false); 2093 SetActive(false);
2100 } 2094 }
2101 2095
2102 2096
2103 } } // namespace v8::internal 2097 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698