| 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 29 matching lines...) Expand all Loading... |
| 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; | 45 var timezone_cache_timezone_offset = NAN; |
| 46 var timezone_cache_timezone; | 46 var timezone_cache_timezone; |
| 47 | 47 |
| 48 function LocalTimezone(t, timezone_offset) { | 48 function LocalTimezone(t, timezone_offset) { |
| 49 if (NUMBER_IS_NAN(t)) return ""; | 49 if (NUMBER_IS_NAN(t)) return ""; |
| 50 CheckDateCacheCurrent(); |
| 50 if (t == timezone_cache_time && | 51 if (t == timezone_cache_time && |
| 51 timezone_offset == timezone_cache_timezone_offset) { | 52 timezone_offset == timezone_cache_timezone_offset) { |
| 52 return timezone_cache_timezone; | 53 return timezone_cache_timezone; |
| 53 } | 54 } |
| 54 var timezone = %DateLocalTimezone(t); | 55 var timezone = %DateLocalTimezone(t); |
| 55 timezone_cache_time = t; | 56 timezone_cache_time = t; |
| 56 timezone_cache_timezone = timezone; | 57 timezone_cache_timezone = timezone; |
| 57 timezone_cache_timezone_offset = timezone_offset; | 58 timezone_cache_timezone_offset = timezone_offset; |
| 58 return timezone; | 59 return timezone; |
| 59 } | 60 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 var value; | 153 var value; |
| 153 if (argc == 0) { | 154 if (argc == 0) { |
| 154 value = %DateCurrentTime(); | 155 value = %DateCurrentTime(); |
| 155 SET_UTC_DATE_VALUE(this, value); | 156 SET_UTC_DATE_VALUE(this, value); |
| 156 } else if (argc == 1) { | 157 } else if (argc == 1) { |
| 157 if (IS_NUMBER(year)) { | 158 if (IS_NUMBER(year)) { |
| 158 value = year; | 159 value = year; |
| 159 } else if (IS_STRING(year)) { | 160 } else if (IS_STRING(year)) { |
| 160 // Probe the Date cache. If we already have a time value for the | 161 // Probe the Date cache. If we already have a time value for the |
| 161 // given time, we re-use that instead of parsing the string again. | 162 // given time, we re-use that instead of parsing the string again. |
| 163 CheckDateCacheCurrent(); |
| 162 var cache = Date_cache; | 164 var cache = Date_cache; |
| 163 if (cache.string === year) { | 165 if (cache.string === year) { |
| 164 value = cache.time; | 166 value = cache.time; |
| 165 } else { | 167 } else { |
| 166 value = DateParse(year); | 168 value = DateParse(year); |
| 167 if (!NUMBER_IS_NAN(value)) { | 169 if (!NUMBER_IS_NAN(value)) { |
| 168 cache.time = value; | 170 cache.time = value; |
| 169 cache.string = year; | 171 cache.string = year; |
| 170 } | 172 } |
| 171 } | 173 } |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 function DateToJSON(key) { | 740 function DateToJSON(key) { |
| 739 var o = ToObject(this); | 741 var o = ToObject(this); |
| 740 var tv = DefaultNumber(o); | 742 var tv = DefaultNumber(o); |
| 741 if (IS_NUMBER(tv) && !NUMBER_IS_FINITE(tv)) { | 743 if (IS_NUMBER(tv) && !NUMBER_IS_FINITE(tv)) { |
| 742 return null; | 744 return null; |
| 743 } | 745 } |
| 744 return o.toISOString(); | 746 return o.toISOString(); |
| 745 } | 747 } |
| 746 | 748 |
| 747 | 749 |
| 748 function ResetDateCache() { | 750 var date_cache_version_holder; |
| 751 var date_cache_version = NAN; |
| 752 |
| 753 |
| 754 function CheckDateCacheCurrent() { |
| 755 if (!date_cache_version_holder) { |
| 756 date_cache_version_holder = %DateCacheVersion(); |
| 757 } |
| 758 if (date_cache_version_holder[0] == date_cache_version) { |
| 759 return; |
| 760 } |
| 761 date_cache_version = date_cache_version_holder[0]; |
| 762 |
| 749 // Reset the timezone cache: | 763 // Reset the timezone cache: |
| 750 timezone_cache_time = NAN; | 764 timezone_cache_time = NAN; |
| 751 timezone_cache_timezone = undefined; | 765 timezone_cache_timezone = undefined; |
| 752 | 766 |
| 753 // Reset the date cache: | 767 // Reset the date cache: |
| 754 cache = Date_cache; | 768 cache = Date_cache; |
| 755 cache.time = NAN; | 769 cache.time = NAN; |
| 756 cache.string = null; | 770 cache.string = null; |
| 757 } | 771 } |
| 758 | 772 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 "toGMTString", DateToGMTString, | 835 "toGMTString", DateToGMTString, |
| 822 "toUTCString", DateToUTCString, | 836 "toUTCString", DateToUTCString, |
| 823 "getYear", DateGetYear, | 837 "getYear", DateGetYear, |
| 824 "setYear", DateSetYear, | 838 "setYear", DateSetYear, |
| 825 "toISOString", DateToISOString, | 839 "toISOString", DateToISOString, |
| 826 "toJSON", DateToJSON | 840 "toJSON", DateToJSON |
| 827 )); | 841 )); |
| 828 } | 842 } |
| 829 | 843 |
| 830 SetUpDate(); | 844 SetUpDate(); |
| OLD | NEW |