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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 | 486 |
487 static bool parseLong(const char* string, char** stopPosition, int base, long* r
esult) | 487 static bool parseLong(const char* string, char** stopPosition, int base, long* r
esult) |
488 { | 488 { |
489 *result = strtol(string, stopPosition, base); | 489 *result = strtol(string, stopPosition, base); |
490 // Avoid the use of errno as it is not available on Windows CE | 490 // Avoid the use of errno as it is not available on Windows CE |
491 if (string == *stopPosition || *result == std::numeric_limits<long>::min() |
| *result == std::numeric_limits<long>::max()) | 491 if (string == *stopPosition || *result == std::numeric_limits<long>::min() |
| *result == std::numeric_limits<long>::max()) |
492 return false; | 492 return false; |
493 return true; | 493 return true; |
494 } | 494 } |
495 | 495 |
496 // Odd case where 'exec' is allowed to be 0, to accomodate a caller in WebCore. | 496 // Odd case where 'exec' is allowed to be 0, to accommodate a caller in WebCore. |
497 static double parseDateFromNullTerminatedCharacters(const char* dateString, bool
& haveTZ, int& offset) | 497 static double parseDateFromNullTerminatedCharacters(const char* dateString, bool
& haveTZ, int& offset) |
498 { | 498 { |
499 haveTZ = false; | 499 haveTZ = false; |
500 offset = 0; | 500 offset = 0; |
501 | 501 |
502 // This parses a date in the form: | 502 // This parses a date in the form: |
503 // Tuesday, 09-Nov-99 23:12:40 GMT | 503 // Tuesday, 09-Nov-99 23:12:40 GMT |
504 // or | 504 // or |
505 // Sat, 01-Jan-2000 08:00:00 GMT | 505 // Sat, 01-Jan-2000 08:00:00 GMT |
506 // or | 506 // or |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 // There was no year; the number was the hour. | 635 // There was no year; the number was the hour. |
636 year = -1; | 636 year = -1; |
637 } else { | 637 } else { |
638 // in the normal case (we parsed the year), advance to the next numb
er | 638 // in the normal case (we parsed the year), advance to the next numb
er |
639 dateString = ++newPosStr; | 639 dateString = ++newPosStr; |
640 skipSpacesAndComments(dateString); | 640 skipSpacesAndComments(dateString); |
641 } | 641 } |
642 | 642 |
643 parseLong(dateString, &newPosStr, 10, &hour); | 643 parseLong(dateString, &newPosStr, 10, &hour); |
644 // Do not check for errno here since we want to continue | 644 // Do not check for errno here since we want to continue |
645 // even if errno was set becasue we are still looking | 645 // even if errno was set because we are still looking |
646 // for the timezone! | 646 // for the timezone! |
647 | 647 |
648 // Read a number? If not, this might be a timezone name. | 648 // Read a number? If not, this might be a timezone name. |
649 if (newPosStr != dateString) { | 649 if (newPosStr != dateString) { |
650 dateString = newPosStr; | 650 dateString = newPosStr; |
651 | 651 |
652 if (hour < 0 || hour > 23) | 652 if (hour < 0 || hour > 23) |
653 return std::numeric_limits<double>::quiet_NaN(); | 653 return std::numeric_limits<double>::quiet_NaN(); |
654 | 654 |
655 if (!*dateString) | 655 if (!*dateString) |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 } | 825 } |
826 | 826 |
827 double convertToLocalTime(double ms) | 827 double convertToLocalTime(double ms) |
828 { | 828 { |
829 double utcOffset = calculateUTCOffset(); | 829 double utcOffset = calculateUTCOffset(); |
830 double dstOffset = calculateDSTOffset(ms, utcOffset); | 830 double dstOffset = calculateDSTOffset(ms, utcOffset); |
831 return (ms + utcOffset + dstOffset); | 831 return (ms + utcOffset + dstOffset); |
832 } | 832 } |
833 | 833 |
834 } // namespace WTF | 834 } // namespace WTF |
OLD | NEW |