OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 offset: 0, | 149 offset: 0, |
150 // Time interval where the cached offset is valid. | 150 // Time interval where the cached offset is valid. |
151 start: 0, end: -1, | 151 start: 0, end: -1, |
152 // Size of next interval expansion. | 152 // Size of next interval expansion. |
153 increment: 0 | 153 increment: 0 |
154 }; | 154 }; |
155 | 155 |
156 | 156 |
157 // NOTE: The implementation relies on the fact that no time zones have | 157 // NOTE: The implementation relies on the fact that no time zones have |
158 // more than one daylight savings offset change per month. | 158 // more than one daylight savings offset change per month. |
159 // This function must never be called with the argument NaN. | 159 // If this function is called with NaN it returns NaN. |
160 // All uses of it are guarded so this does not happen. | |
161 function DaylightSavingsOffset(t) { | 160 function DaylightSavingsOffset(t) { |
162 // Load the cache object from the builtins object. | 161 // Load the cache object from the builtins object. |
163 var cache = DST_offset_cache; | 162 var cache = DST_offset_cache; |
164 | 163 |
165 // Cache the start and the end in local variables for fast access. | 164 // Cache the start and the end in local variables for fast access. |
166 var start = cache.start; | 165 var start = cache.start; |
167 var end = cache.end; | 166 var end = cache.end; |
168 | 167 |
169 if (start <= t) { | 168 if (start <= t) { |
170 // If the time fits in the cached interval, return the cached offset. | 169 // If the time fits in the cached interval, return the cached offset. |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 | 644 |
646 | 645 |
647 function TimeString(time) { | 646 function TimeString(time) { |
648 return TwoDigitString(HourFromTime(time)) + ':' | 647 return TwoDigitString(HourFromTime(time)) + ':' |
649 + TwoDigitString(MinFromTime(time)) + ':' | 648 + TwoDigitString(MinFromTime(time)) + ':' |
650 + TwoDigitString(SecFromTime(time)); | 649 + TwoDigitString(SecFromTime(time)); |
651 } | 650 } |
652 | 651 |
653 | 652 |
654 function LocalTimezoneString(time) { | 653 function LocalTimezoneString(time) { |
655 // time is not NaN because of checks in calling functions. | 654 var timezoneOffset = |
656 var timezoneOffset = (local_time_offset + DaylightSavingsOffset(time)) / msPer
Minute; | 655 (local_time_offset + DaylightSavingsOffset(time)) / msPerMinute; |
657 var sign = (timezoneOffset >= 0) ? 1 : -1; | 656 var sign = (timezoneOffset >= 0) ? 1 : -1; |
658 var hours = FLOOR((sign * timezoneOffset)/60); | 657 var hours = FLOOR((sign * timezoneOffset)/60); |
659 var min = FLOOR((sign * timezoneOffset)%60); | 658 var min = FLOOR((sign * timezoneOffset)%60); |
660 var gmt = ' GMT' + ((sign == 1) ? '+' : '-') + TwoDigitString(hours) + TwoDigi
tString(min); | 659 var gmt = ' GMT' + ((sign == 1) ? '+' : '-') + |
| 660 TwoDigitString(hours) + TwoDigitString(min); |
661 return gmt + ' (' + LocalTimezone(time) + ')'; | 661 return gmt + ' (' + LocalTimezone(time) + ')'; |
662 } | 662 } |
663 | 663 |
664 | 664 |
665 function DatePrintString(time) { | 665 function DatePrintString(time) { |
666 return DateString(time) + ' ' + TimeString(time); | 666 return DateString(time) + ' ' + TimeString(time); |
667 } | 667 } |
668 | 668 |
669 // ------------------------------------------------------------------- | 669 // ------------------------------------------------------------------- |
670 | 670 |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 "toGMTString", DateToGMTString, | 1164 "toGMTString", DateToGMTString, |
1165 "toUTCString", DateToUTCString, | 1165 "toUTCString", DateToUTCString, |
1166 "getYear", DateGetYear, | 1166 "getYear", DateGetYear, |
1167 "setYear", DateSetYear, | 1167 "setYear", DateSetYear, |
1168 "toISOString", DateToISOString, | 1168 "toISOString", DateToISOString, |
1169 "toJSON", DateToJSON | 1169 "toJSON", DateToJSON |
1170 )); | 1170 )); |
1171 } | 1171 } |
1172 | 1172 |
1173 SetupDate(); | 1173 SetupDate(); |
OLD | NEW |