Contents of /trunk/spidermonkey/patches/spidermonkey-60.7.2-fix-timezone-issues.patch
Parent Directory | Revision Log
Revision 3364 -
(show annotations)
(download)
Fri Jun 28 12:23:19 2019 UTC (5 years, 4 months ago) by niro
File size: 4886 byte(s)
Fri Jun 28 12:23:19 2019 UTC (5 years, 4 months ago) by niro
File size: 4886 byte(s)
-added spidermonkey-60.7.2 patches
1 | # HG changeset patch |
2 | # User André Bargull <andre.bargull@gmail.com> |
3 | # Date 1510140221 28800 |
4 | # Wed Nov 08 03:23:41 2017 -0800 |
5 | # Node ID 8bf5e7460a7c5ba3430b501d1659c469a862a929 |
6 | # Parent 60fd4a5b01ec70ded9ddfd560fd5be191b1c74b9 |
7 | Bug 1415202: Always use the equivalent year to determine the time zone offset and name. r=Waldo |
8 | |
9 | diff --git a/js/src/jsdate.cpp b/js/src/jsdate.cpp |
10 | --- a/js/src/jsdate.cpp |
11 | +++ b/js/src/jsdate.cpp |
12 | @@ -2348,22 +2348,26 @@ static PRMJTime ToPRMJTime(double localT |
13 | prtm.tm_isdst = (DaylightSavingTA(utcTime) != 0); |
14 | |
15 | return prtm; |
16 | } |
17 | |
18 | static size_t FormatTime(char* buf, int buflen, const char* fmt, double utcTime, |
19 | double localTime) { |
20 | PRMJTime prtm = ToPRMJTime(localTime, utcTime); |
21 | - int eqivalentYear = IsRepresentableAsTime32(utcTime) |
22 | + |
23 | + // If an equivalent year was used to compute the date/time components, use |
24 | + // the same equivalent year to determine the time zone name and offset in |
25 | + // PRMJ_FormatTime(...). |
26 | + int timeZoneYear = IsRepresentableAsTime32(utcTime) |
27 | ? prtm.tm_year |
28 | : EquivalentYearForDST(prtm.tm_year); |
29 | int offsetInSeconds = (int)floor((localTime - utcTime) / msPerSecond); |
30 | |
31 | - return PRMJ_FormatTime(buf, buflen, fmt, &prtm, eqivalentYear, |
32 | + return PRMJ_FormatTime(buf, buflen, fmt, &prtm, timeZoneYear, |
33 | offsetInSeconds); |
34 | } |
35 | |
36 | enum class FormatSpec { DateTime, Date, Time }; |
37 | |
38 | static bool FormatDate(JSContext* cx, double utcTime, FormatSpec format, |
39 | MutableHandleValue rval) { |
40 | JSString* str; |
41 | diff --git a/js/src/vm/Time.cpp b/js/src/vm/Time.cpp |
42 | --- a/js/src/vm/Time.cpp |
43 | +++ b/js/src/vm/Time.cpp |
44 | @@ -242,17 +242,17 @@ static void PRMJ_InvalidParameterHandler |
45 | const wchar_t* file, unsigned int line, |
46 | uintptr_t pReserved) { |
47 | /* empty */ |
48 | } |
49 | #endif |
50 | |
51 | /* Format a time value into a buffer. Same semantics as strftime() */ |
52 | size_t PRMJ_FormatTime(char* buf, int buflen, const char* fmt, |
53 | - const PRMJTime* prtm, int equivalentYear, |
54 | + const PRMJTime* prtm, int timeZoneYear, |
55 | int offsetInSeconds) { |
56 | size_t result = 0; |
57 | #if defined(XP_UNIX) || defined(XP_WIN) |
58 | struct tm a; |
59 | #ifdef XP_WIN |
60 | _invalid_parameter_handler oldHandler; |
61 | #ifndef __MINGW32__ |
62 | int oldReportMode; |
63 | @@ -275,39 +275,33 @@ size_t PRMJ_FormatTime(char* buf, int bu |
64 | */ |
65 | #if defined(HAVE_LOCALTIME_R) && defined(HAVE_TM_ZONE_TM_GMTOFF) |
66 | char emptyTimeZoneId[] = ""; |
67 | { |
68 | /* |
69 | * Fill out |td| to the time represented by |prtm|, leaving the |
70 | * timezone fields zeroed out. localtime_r will then fill in the |
71 | * timezone fields for that local time according to the system's |
72 | - * timezone parameters. |
73 | + * timezone parameters. Use |timeZoneYear| for the year to ensure the |
74 | + * time zone name matches the time zone offset used by the caller. |
75 | */ |
76 | struct tm td; |
77 | memset(&td, 0, sizeof(td)); |
78 | td.tm_sec = prtm->tm_sec; |
79 | td.tm_min = prtm->tm_min; |
80 | td.tm_hour = prtm->tm_hour; |
81 | td.tm_mday = prtm->tm_mday; |
82 | td.tm_mon = prtm->tm_mon; |
83 | td.tm_wday = prtm->tm_wday; |
84 | - td.tm_year = prtm->tm_year - 1900; |
85 | + td.tm_year = timeZoneYear - 1900; |
86 | td.tm_yday = prtm->tm_yday; |
87 | td.tm_isdst = prtm->tm_isdst; |
88 | |
89 | time_t t = mktime(&td); |
90 | |
91 | - // If |prtm| cannot be represented in |time_t| the year is probably |
92 | - // out of range, try again with the DST equivalent year. |
93 | - if (t == static_cast<time_t>(-1)) { |
94 | - td.tm_year = equivalentYear - 1900; |
95 | - t = mktime(&td); |
96 | - } |
97 | - |
98 | // If either mktime or localtime_r failed, fill in the fallback time |
99 | // zone offset |offsetInSeconds| and set the time zone identifier to |
100 | // the empty string. |
101 | if (t != static_cast<time_t>(-1) && localtime_r(&t, &td)) { |
102 | a.tm_gmtoff = td.tm_gmtoff; |
103 | a.tm_zone = td.tm_zone; |
104 | } else { |
105 | a.tm_gmtoff = offsetInSeconds; |
106 | diff --git a/js/src/vm/Time.h b/js/src/vm/Time.h |
107 | --- a/js/src/vm/Time.h |
108 | +++ b/js/src/vm/Time.h |
109 | @@ -44,17 +44,17 @@ inline void PRMJ_NowInit() {} |
110 | #ifdef XP_WIN |
111 | extern void PRMJ_NowShutdown(); |
112 | #else |
113 | inline void PRMJ_NowShutdown() {} |
114 | #endif |
115 | |
116 | /* Format a time value into a buffer. Same semantics as strftime() */ |
117 | extern size_t PRMJ_FormatTime(char* buf, int buflen, const char* fmt, |
118 | - const PRMJTime* tm, int equivalentYear, |
119 | + const PRMJTime* tm, int timeZoneYear, |
120 | int offsetInSeconds); |
121 | |
122 | /** |
123 | * Requesting the number of cycles from the CPU. |
124 | * |
125 | * `rdtsc`, or Read TimeStamp Cycle, is an instruction provided by |
126 | * x86-compatible CPUs that lets processes request the number of |
127 | * cycles spent by the CPU executing instructions since the CPU was |