@@ -1314,7 +1314,7 @@ index 9e2bee913d37c79fedbb918176a43022b84fa45b..ad8926d773144114dad3842fa0fe2391
1314
1314
},
1315
1315
{
1316
1316
diff --git a/Source/JavaScriptCore/runtime/DateConversion.cpp b/Source/JavaScriptCore/runtime/DateConversion.cpp
1317
- index 955756ba405f400970610f9a68c7ed42a67cb015..6e281fc075425a324fd30a4608e9e97d547044f2 100644
1317
+ index 955756ba405f400970610f9a68c7ed42a67cb015..1520c0a1475a90de2795e4ccd8919c1bb1384066 100644
1318
1318
--- a/Source/JavaScriptCore/runtime/DateConversion.cpp
1319
1319
+++ b/Source/JavaScriptCore/runtime/DateConversion.cpp
1320
1320
@@ -100,17 +100,23 @@ String formatDateTime(const GregorianDateTime& t, DateTimeFormat format, bool as
@@ -1327,8 +1327,8 @@ index 955756ba405f400970610f9a68c7ed42a67cb015..6e281fc075425a324fd30a4608e9e97d
1327
1327
- const WCHAR* winTimeZoneName = t.isDST() ? timeZoneInformation.DaylightName : timeZoneInformation.StandardName;
1328
1328
- String timeZoneName(winTimeZoneName);
1329
1329
+ String timeZoneName;
1330
- + if (!WTF::timeZoneForAutomation ().isEmpty()) {
1331
- + timeZoneName = WTF::timeZoneForAutomation ();
1330
+ + if (!WTF::timeZoneDisplayNameForAutomation ().isEmpty()) {
1331
+ + timeZoneName = WTF::timeZoneDisplayNameForAutomation ();
1332
1332
+ } else {
1333
1333
+ #if OS(WINDOWS)
1334
1334
+ TIME_ZONE_INFORMATION timeZoneInformation;
@@ -1374,16 +1374,17 @@ index 9817a45ea2f3a22844ed3e56816cff94eb051423..67f7459a556ed22740fbfcd2b1b7b530
1374
1374
// The DefaultTimeZone abstract operation returns a String value representing the valid (6.4.1) and canonicalized (6.4.2) time zone name for the host environment’s current time zone.
1375
1375
1376
1376
diff --git a/Source/WTF/wtf/DateMath.cpp b/Source/WTF/wtf/DateMath.cpp
1377
- index 1999737341553001d5246b8190e9ea11d615a158..1b09b2a2a6b78a80aaf8a45dad984e7628fc5188 100644
1377
+ index 1999737341553001d5246b8190e9ea11d615a158..540ed892bca8110f8013477da7bd9b459a17e60d 100644
1378
1378
--- a/Source/WTF/wtf/DateMath.cpp
1379
1379
+++ b/Source/WTF/wtf/DateMath.cpp
1380
- @@ -77,11 +77,15 @@
1380
+ @@ -77,11 +77,16 @@
1381
1381
#include <limits>
1382
1382
#include <stdint.h>
1383
1383
#include <time.h>
1384
1384
+#include <unicode/ucal.h>
1385
1385
#include <wtf/Assertions.h>
1386
1386
#include <wtf/ASCIICType.h>
1387
+ +#include <wtf/Language.h>
1387
1388
#include <wtf/MathExtras.h>
1388
1389
+#include <wtf/NeverDestroyed.h>
1389
1390
#include <wtf/StdLibExtras.h>
@@ -1393,13 +1394,14 @@ index 1999737341553001d5246b8190e9ea11d615a158..1b09b2a2a6b78a80aaf8a45dad984e76
1393
1394
1394
1395
#if OS(WINDOWS)
1395
1396
#include <windows.h>
1396
- @@ -107,6 +111,17 @@ template<unsigned length> inline bool startsWithLettersIgnoringASCIICase(const c
1397
+ @@ -107,6 +112,18 @@ template<unsigned length> inline bool startsWithLettersIgnoringASCIICase(const c
1397
1398
return equalLettersIgnoringASCIICase(string, lowercaseLetters, length - 1);
1398
1399
}
1399
1400
1400
1401
+struct TimeZoneForAutomation {
1401
1402
+ UCalendar* cal;
1402
- + String name;
1403
+ + String id;
1404
+ + String displayName;
1403
1405
+};
1404
1406
+
1405
1407
+static TimeZoneForAutomation& innerTimeZoneForAutomation()
@@ -1411,7 +1413,7 @@ index 1999737341553001d5246b8190e9ea11d615a158..1b09b2a2a6b78a80aaf8a45dad984e76
1411
1413
/* Constants */
1412
1414
1413
1415
const char* const weekdayName[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
1414
- @@ -333,6 +348 ,14 @@ static double calculateDSTOffset(time_t localTime, double utcOffset)
1416
+ @@ -333,6 +350 ,14 @@ static double calculateDSTOffset(time_t localTime, double utcOffset)
1415
1417
// Returns combined offset in millisecond (UTC + DST).
1416
1418
LocalTimeOffset calculateLocalTimeOffset(double ms, TimeType inputTimeType)
1417
1419
{
@@ -1426,18 +1428,19 @@ index 1999737341553001d5246b8190e9ea11d615a158..1b09b2a2a6b78a80aaf8a45dad984e76
1426
1428
#if HAVE(TM_GMTOFF)
1427
1429
double localToUTCTimeOffset = inputTimeType == LocalTime ? calculateUTCOffset() : 0;
1428
1430
#else
1429
- @@ -1034,4 +1057,46 @@ String makeRFC2822DateString(unsigned dayOfWeek, unsigned day, unsigned month, u
1431
+ @@ -1034,4 +1059,65 @@ String makeRFC2822DateString(unsigned dayOfWeek, unsigned day, unsigned month, u
1430
1432
return stringBuilder.toString();
1431
1433
}
1432
1434
1433
1435
+bool setTimeZoneForAutomation(const String& timeZone)
1434
1436
+{
1437
+ + innerTimeZoneForAutomation().displayName = String();
1435
1438
+ if (innerTimeZoneForAutomation().cal) {
1436
1439
+ ucal_close(innerTimeZoneForAutomation().cal);
1437
1440
+ innerTimeZoneForAutomation().cal = nullptr;
1438
1441
+ }
1439
1442
+ if (timeZone.isEmpty()) {
1440
- + innerTimeZoneForAutomation().name = String();
1443
+ + innerTimeZoneForAutomation().id = String();
1441
1444
+ return true;
1442
1445
+ }
1443
1446
+
@@ -1459,30 +1462,49 @@ index 1999737341553001d5246b8190e9ea11d615a158..1b09b2a2a6b78a80aaf8a45dad984e76
1459
1462
+ if (!U_SUCCESS(status))
1460
1463
+ return false;
1461
1464
+
1462
- + innerTimeZoneForAutomation(). cal = ucal_open(canonicalBuffer.data(), canonicalLength, nullptr, UCAL_TRADITIONAL, &status);
1465
+ + UCalendar* cal = ucal_open(canonicalBuffer.data(), canonicalLength, nullptr, UCAL_TRADITIONAL, &status);
1463
1466
+ if (!U_SUCCESS(status))
1464
1467
+ return false;
1465
1468
+
1466
- + innerTimeZoneForAutomation().name = String(canonicalBuffer.data(), canonicalLength);
1469
+ + Vector<UChar, 32> displayNameBuffer(32);
1470
+ + auto displayNameLength = ucal_getTimeZoneDisplayName(cal, UCAL_STANDARD, defaultLanguage().utf8().data(), displayNameBuffer.data(), displayNameBuffer.size(), &status);
1471
+ + if (status == U_BUFFER_OVERFLOW_ERROR) {
1472
+ + status = U_ZERO_ERROR;
1473
+ + displayNameBuffer.grow(displayNameLength);
1474
+ + ucal_getTimeZoneDisplayName(cal, UCAL_STANDARD, defaultLanguage().utf8().data(), displayNameBuffer.data(), displayNameLength, &status);
1475
+ + }
1476
+ + if (!U_SUCCESS(status))
1477
+ + return false;
1478
+ +
1479
+ + TimeZoneForAutomation& tzfa = innerTimeZoneForAutomation();
1480
+ + tzfa.cal = cal;
1481
+ + tzfa.id = String(canonicalBuffer.data(), canonicalLength);
1482
+ + tzfa.displayName = String(displayNameBuffer.data(), displayNameLength);
1467
1483
+ return true;
1468
1484
+}
1469
1485
+
1470
1486
+String timeZoneForAutomation()
1471
1487
+{
1472
- + return innerTimeZoneForAutomation().name;
1488
+ + return innerTimeZoneForAutomation().id;
1489
+ +}
1490
+ +
1491
+ +String timeZoneDisplayNameForAutomation()
1492
+ +{
1493
+ + return innerTimeZoneForAutomation().displayName;
1473
1494
+}
1474
1495
+
1475
1496
} // namespace WTF
1476
1497
diff --git a/Source/WTF/wtf/DateMath.h b/Source/WTF/wtf/DateMath.h
1477
- index 602f89a49d454cc5e5acd030024227d49d98c61f..66da6661c0c7e2c13808b90ecce19884157487a7 100644
1498
+ index 602f89a49d454cc5e5acd030024227d49d98c61f..41811e65bd0f15b443fb90d37ee4d0a21780a518 100644
1478
1499
--- a/Source/WTF/wtf/DateMath.h
1479
1500
+++ b/Source/WTF/wtf/DateMath.h
1480
- @@ -389,6 +389,9 @@ inline int dayInMonthFromDayInYear(int dayInYear, bool leapYear)
1501
+ @@ -389,6 +389,10 @@ inline int dayInMonthFromDayInYear(int dayInYear, bool leapYear)
1481
1502
return d - step;
1482
1503
}
1483
1504
1484
1505
+WTF_EXPORT_PRIVATE bool setTimeZoneForAutomation(const String& timeZone);
1485
1506
+WTF_EXPORT_PRIVATE String timeZoneForAutomation();
1507
+ +WTF_EXPORT_PRIVATE String timeZoneDisplayNameForAutomation();
1486
1508
+
1487
1509
// Returns combined offset in millisecond (UTC + DST).
1488
1510
WTF_EXPORT_PRIVATE LocalTimeOffset calculateLocalTimeOffset(double utcInMilliseconds, TimeType = UTCTime);
0 commit comments