| 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 // This file contains date support implemented in JavaScript. | 36 // This file contains date support implemented in JavaScript. |
| 37 | 37 |
| 38 // Helper function to throw error. | 38 // Helper function to throw error. |
| 39 function ThrowDateTypeError() { | 39 function ThrowDateTypeError() { |
| 40 throw new $TypeError('this is not a Date object.'); | 40 throw new $TypeError('this is not a Date object.'); |
| 41 } | 41 } |
| 42 | 42 |
| 43 | 43 |
| 44 var timezone_cache_time = NAN; | 44 var timezone_cache_time = NAN; |
| 45 var timezone_cache_timezone_offset = NAN; | |
| 46 var timezone_cache_timezone; | 45 var timezone_cache_timezone; |
| 47 | 46 |
| 48 function LocalTimezone(t, timezone_offset) { | 47 function LocalTimezone(t) { |
| 49 if (NUMBER_IS_NAN(t)) return ""; | 48 if (NUMBER_IS_NAN(t)) return ""; |
| 50 if (t == timezone_cache_time && | 49 if (t == timezone_cache_time) { |
| 51 timezone_offset == timezone_cache_timezone_offset) { | |
| 52 return timezone_cache_timezone; | 50 return timezone_cache_timezone; |
| 53 } | 51 } |
| 54 var timezone = %DateLocalTimezone(t); | 52 var timezone = %DateLocalTimezone(t); |
| 55 timezone_cache_time = t; | 53 timezone_cache_time = t; |
| 56 timezone_cache_timezone = timezone; | 54 timezone_cache_timezone = timezone; |
| 57 timezone_cache_timezone_offset = timezone_offset; | |
| 58 return timezone; | 55 return timezone; |
| 59 } | 56 } |
| 60 | 57 |
| 61 | 58 |
| 62 function UTC(time) { | 59 function UTC(time) { |
| 63 if (NUMBER_IS_NAN(time)) return time; | 60 if (NUMBER_IS_NAN(time)) return time; |
| 64 // local_time_offset is needed before the call to DaylightSavingsOffset, | 61 // local_time_offset is needed before the call to DaylightSavingsOffset, |
| 65 // so it may be uninitialized. | 62 // so it may be uninitialized. |
| 66 return %DateToUTC(time); | 63 return %DateToUTC(time); |
| 67 } | 64 } |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 238 |
| 242 | 239 |
| 243 function TimeStringUTC(date) { | 240 function TimeStringUTC(date) { |
| 244 return TwoDigitString(UTC_HOUR(date)) + ':' | 241 return TwoDigitString(UTC_HOUR(date)) + ':' |
| 245 + TwoDigitString(UTC_MIN(date)) + ':' | 242 + TwoDigitString(UTC_MIN(date)) + ':' |
| 246 + TwoDigitString(UTC_SEC(date)); | 243 + TwoDigitString(UTC_SEC(date)); |
| 247 } | 244 } |
| 248 | 245 |
| 249 | 246 |
| 250 function LocalTimezoneString(date) { | 247 function LocalTimezoneString(date) { |
| 248 var timezone = LocalTimezone(UTC_DATE_VALUE(date)); |
| 249 |
| 251 var timezoneOffset = -TIMEZONE_OFFSET(date); | 250 var timezoneOffset = -TIMEZONE_OFFSET(date); |
| 252 var timezone = LocalTimezone(UTC_DATE_VALUE(date), timezoneOffset); | |
| 253 var sign = (timezoneOffset >= 0) ? 1 : -1; | 251 var sign = (timezoneOffset >= 0) ? 1 : -1; |
| 254 var hours = FLOOR((sign * timezoneOffset)/60); | 252 var hours = FLOOR((sign * timezoneOffset)/60); |
| 255 var min = FLOOR((sign * timezoneOffset)%60); | 253 var min = FLOOR((sign * timezoneOffset)%60); |
| 256 var gmt = ' GMT' + ((sign == 1) ? '+' : '-') + | 254 var gmt = ' GMT' + ((sign == 1) ? '+' : '-') + |
| 257 TwoDigitString(hours) + TwoDigitString(min); | 255 TwoDigitString(hours) + TwoDigitString(min); |
| 258 return gmt + ' (' + timezone + ')'; | 256 return gmt + ' (' + timezone + ')'; |
| 259 } | 257 } |
| 260 | 258 |
| 261 | 259 |
| 262 function DatePrintString(date) { | 260 function DatePrintString(date) { |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 "toGMTString", DateToGMTString, | 819 "toGMTString", DateToGMTString, |
| 822 "toUTCString", DateToUTCString, | 820 "toUTCString", DateToUTCString, |
| 823 "getYear", DateGetYear, | 821 "getYear", DateGetYear, |
| 824 "setYear", DateSetYear, | 822 "setYear", DateSetYear, |
| 825 "toISOString", DateToISOString, | 823 "toISOString", DateToISOString, |
| 826 "toJSON", DateToJSON | 824 "toJSON", DateToJSON |
| 827 )); | 825 )); |
| 828 } | 826 } |
| 829 | 827 |
| 830 SetUpDate(); | 828 SetUpDate(); |
| OLD | NEW |