Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Side by Side Diff: src/date.js

Issue 173793002: Check and clear date cache in DateCurrentTime, DateLocalTimezone and getTimezoneOffset. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix caching of offset Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/date.h ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
45 var timezone_cache_timezone; 46 var timezone_cache_timezone;
46 47
47 function LocalTimezone(t) { 48 function LocalTimezone(t, timezone_offset) {
48 if (NUMBER_IS_NAN(t)) return ""; 49 if (NUMBER_IS_NAN(t)) return "";
49 if (t == timezone_cache_time) { 50 if (t == timezone_cache_time &&
51 timezone_offset == timezone_cache_timezone_offset) {
50 return timezone_cache_timezone; 52 return timezone_cache_timezone;
51 } 53 }
52 var timezone = %DateLocalTimezone(t); 54 var timezone = %DateLocalTimezone(t);
53 timezone_cache_time = t; 55 timezone_cache_time = t;
54 timezone_cache_timezone = timezone; 56 timezone_cache_timezone = timezone;
57 timezone_cache_timezone_offset = timezone_offset;
55 return timezone; 58 return timezone;
56 } 59 }
57 60
58 61
59 function UTC(time) { 62 function UTC(time) {
60 if (NUMBER_IS_NAN(time)) return time; 63 if (NUMBER_IS_NAN(time)) return time;
61 // local_time_offset is needed before the call to DaylightSavingsOffset, 64 // local_time_offset is needed before the call to DaylightSavingsOffset,
62 // so it may be uninitialized. 65 // so it may be uninitialized.
63 return %DateToUTC(time); 66 return %DateToUTC(time);
64 } 67 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 241
239 242
240 function TimeStringUTC(date) { 243 function TimeStringUTC(date) {
241 return TwoDigitString(UTC_HOUR(date)) + ':' 244 return TwoDigitString(UTC_HOUR(date)) + ':'
242 + TwoDigitString(UTC_MIN(date)) + ':' 245 + TwoDigitString(UTC_MIN(date)) + ':'
243 + TwoDigitString(UTC_SEC(date)); 246 + TwoDigitString(UTC_SEC(date));
244 } 247 }
245 248
246 249
247 function LocalTimezoneString(date) { 250 function LocalTimezoneString(date) {
248 var timezone = LocalTimezone(UTC_DATE_VALUE(date));
249
250 var timezoneOffset = -TIMEZONE_OFFSET(date); 251 var timezoneOffset = -TIMEZONE_OFFSET(date);
252 var timezone = LocalTimezone(UTC_DATE_VALUE(date), timezoneOffset);
251 var sign = (timezoneOffset >= 0) ? 1 : -1; 253 var sign = (timezoneOffset >= 0) ? 1 : -1;
252 var hours = FLOOR((sign * timezoneOffset)/60); 254 var hours = FLOOR((sign * timezoneOffset)/60);
253 var min = FLOOR((sign * timezoneOffset)%60); 255 var min = FLOOR((sign * timezoneOffset)%60);
254 var gmt = ' GMT' + ((sign == 1) ? '+' : '-') + 256 var gmt = ' GMT' + ((sign == 1) ? '+' : '-') +
255 TwoDigitString(hours) + TwoDigitString(min); 257 TwoDigitString(hours) + TwoDigitString(min);
256 return gmt + ' (' + timezone + ')'; 258 return gmt + ' (' + timezone + ')';
257 } 259 }
258 260
259 261
260 function DatePrintString(date) { 262 function DatePrintString(date) {
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 "toGMTString", DateToGMTString, 821 "toGMTString", DateToGMTString,
820 "toUTCString", DateToUTCString, 822 "toUTCString", DateToUTCString,
821 "getYear", DateGetYear, 823 "getYear", DateGetYear,
822 "setYear", DateSetYear, 824 "setYear", DateSetYear,
823 "toISOString", DateToISOString, 825 "toISOString", DateToISOString,
824 "toJSON", DateToJSON 826 "toJSON", DateToJSON
825 )); 827 ));
826 } 828 }
827 829
828 SetUpDate(); 830 SetUpDate();
OLDNEW
« no previous file with comments | « src/date.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698