| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) | 2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) |
| 3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2009 Google Inc. All rights reserved. | 4 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 5 * Copyright (C) 2007-2009 Torch Mobile, Inc. | 5 * Copyright (C) 2007-2009 Torch Mobile, Inc. |
| 6 * Copyright (C) 2010 &yet, LLC. (nate@andyet.net) | 6 * Copyright (C) 2010 &yet, LLC. (nate@andyet.net) |
| 7 * | 7 * |
| 8 * The Original Code is Mozilla Communicator client code, released | 8 * The Original Code is Mozilla Communicator client code, released |
| 9 * March 31, 1998. | 9 * March 31, 1998. |
| 10 * | 10 * |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 #include "StdLibExtras.h" | 79 #include "StdLibExtras.h" |
| 80 #include "StringExtras.h" | 80 #include "StringExtras.h" |
| 81 | 81 |
| 82 #include <algorithm> | 82 #include <algorithm> |
| 83 #include <limits.h> | 83 #include <limits.h> |
| 84 #include <limits> | 84 #include <limits> |
| 85 #include <stdint.h> | 85 #include <stdint.h> |
| 86 #include <time.h> | 86 #include <time.h> |
| 87 #include "wtf/text/StringBuilder.h" | 87 #include "wtf/text/StringBuilder.h" |
| 88 | 88 |
| 89 #if OS(WINDOWS) | 89 #if OS(WIN) |
| 90 #include <windows.h> | 90 #include <windows.h> |
| 91 #endif | 91 #endif |
| 92 | 92 |
| 93 #if HAVE(SYS_TIME_H) | 93 #if HAVE(SYS_TIME_H) |
| 94 #include <sys/time.h> | 94 #include <sys/time.h> |
| 95 #endif | 95 #endif |
| 96 | 96 |
| 97 using namespace WTF; | 97 using namespace WTF; |
| 98 | 98 |
| 99 namespace WTF { | 99 namespace WTF { |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 int quotient = difference / 28; | 352 int quotient = difference / 28; |
| 353 int product = (quotient) * 28; | 353 int product = (quotient) * 28; |
| 354 | 354 |
| 355 year += product; | 355 year += product; |
| 356 ASSERT((year >= minYear && year <= maxYear) || (product - year == static_cas
t<int>(std::numeric_limits<double>::quiet_NaN()))); | 356 ASSERT((year >= minYear && year <= maxYear) || (product - year == static_cas
t<int>(std::numeric_limits<double>::quiet_NaN()))); |
| 357 return year; | 357 return year; |
| 358 } | 358 } |
| 359 | 359 |
| 360 int32_t calculateUTCOffset() | 360 int32_t calculateUTCOffset() |
| 361 { | 361 { |
| 362 #if OS(WINDOWS) | 362 #if OS(WIN) |
| 363 TIME_ZONE_INFORMATION timeZoneInformation; | 363 TIME_ZONE_INFORMATION timeZoneInformation; |
| 364 GetTimeZoneInformation(&timeZoneInformation); | 364 GetTimeZoneInformation(&timeZoneInformation); |
| 365 int32_t bias = timeZoneInformation.Bias + timeZoneInformation.StandardBias; | 365 int32_t bias = timeZoneInformation.Bias + timeZoneInformation.StandardBias; |
| 366 return -bias * 60 * 1000; | 366 return -bias * 60 * 1000; |
| 367 #else | 367 #else |
| 368 time_t localTime = time(0); | 368 time_t localTime = time(0); |
| 369 tm localt; | 369 tm localt; |
| 370 getLocalTime(&localTime, &localt); | 370 getLocalTime(&localTime, &localt); |
| 371 | 371 |
| 372 // Get the difference between this time zone and UTC on the 1st of January o
f this year. | 372 // Get the difference between this time zone and UTC on the 1st of January o
f this year. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 + floor(1461 * (year + 4800.0 + (mon - 14) / 12) / 4) | 468 + floor(1461 * (year + 4800.0 + (mon - 14) / 12) / 4) |
| 469 + 367 * (mon - 2 - (mon - 14) / 12 * 12) / 12 | 469 + 367 * (mon - 2 - (mon - 14) / 12 * 12) / 12 |
| 470 - floor(3 * ((year + 4900.0 + (mon - 14) / 12) / 100) / 4) | 470 - floor(3 * ((year + 4900.0 + (mon - 14) / 12) / 100) / 4) |
| 471 - 2440588; | 471 - 2440588; |
| 472 return ((days * hoursPerDay + hour) * minutesPerHour + minute) * secondsPerM
inute + second; | 472 return ((days * hoursPerDay + hour) * minutesPerHour + minute) * secondsPerM
inute + second; |
| 473 } | 473 } |
| 474 | 474 |
| 475 // We follow the recommendation of RFC 2822 to consider all | 475 // We follow the recommendation of RFC 2822 to consider all |
| 476 // obsolete time zones not listed here equivalent to "-0000". | 476 // obsolete time zones not listed here equivalent to "-0000". |
| 477 static const struct KnownZone { | 477 static const struct KnownZone { |
| 478 #if !OS(WINDOWS) | 478 #if !OS(WIN) |
| 479 const | 479 const |
| 480 #endif | 480 #endif |
| 481 char tzName[4]; | 481 char tzName[4]; |
| 482 int tzOffset; | 482 int tzOffset; |
| 483 } known_zones[] = { | 483 } known_zones[] = { |
| 484 { "UT", 0 }, | 484 { "UT", 0 }, |
| 485 { "GMT", 0 }, | 485 { "GMT", 0 }, |
| 486 { "EST", -300 }, | 486 { "EST", -300 }, |
| 487 { "EDT", -240 }, | 487 { "EDT", -240 }, |
| 488 { "CST", -360 }, | 488 { "CST", -360 }, |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 | 1078 |
| 1079 stringBuilder.append(utcOffset > 0 ? '+' : '-'); | 1079 stringBuilder.append(utcOffset > 0 ? '+' : '-'); |
| 1080 int absoluteUTCOffset = abs(utcOffset); | 1080 int absoluteUTCOffset = abs(utcOffset); |
| 1081 stringBuilder.append(twoDigitStringFromNumber(absoluteUTCOffset / 60)); | 1081 stringBuilder.append(twoDigitStringFromNumber(absoluteUTCOffset / 60)); |
| 1082 stringBuilder.append(twoDigitStringFromNumber(absoluteUTCOffset % 60)); | 1082 stringBuilder.append(twoDigitStringFromNumber(absoluteUTCOffset % 60)); |
| 1083 | 1083 |
| 1084 return stringBuilder.toString(); | 1084 return stringBuilder.toString(); |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1087 } // namespace WTF | 1087 } // namespace WTF |
| OLD | NEW |