From 03d999df90d090e1a6f856e5978b12b293ba86da Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 24 May 2023 13:10:24 -0700 Subject: [PATCH 01/38] Handle time zone environment variable having international characters. --- app/src/locale.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index c007208cef..3fc70f00fb 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -29,12 +29,14 @@ #elif FIREBASE_PLATFORM_LINUX #include #include -#include #else #error "Unknown platform." #endif // platform selector #include +#include +#include +#include #include namespace firebase { @@ -91,11 +93,13 @@ std::string GetLocale() { std::string GetTimezone() { #if FIREBASE_PLATFORM_WINDOWS // If "TZ" environment variable is defined, use it, else use _get_tzname. - int tz_bytes = GetEnvironmentVariable("TZ", nullptr, 0); - if (tz_bytes > 0) { - std::vector buffer(tz_bytes); - GetEnvironmentVariable("TZ", &buffer[0], tz_bytes); - return std::string(&buffer[0]); + int tz_chars = GetEnvironmentVariableW("TZ", nullptr, 0); + if (tz_chars > 0) { + std::vector buffer(tz_chars + 1); + GetEnvironmentVariableW("TZ", &buffer[0], tz_chars); + std::wstring tz_utf16(&buffer[0]); + std::wstring_convert, wchar_t> converter; + return converter.to_bytes(wstring_string); } int daylight; // daylight savings time? if (_get_daylight(&daylight) != 0) return ""; From 95c473e08e88bd65444d380b942886e918cc0616 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 25 May 2023 12:15:29 -0700 Subject: [PATCH 02/38] Fix environment variable string. --- app/src/locale.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index 3fc70f00fb..64ac5672e7 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -93,10 +93,10 @@ std::string GetLocale() { std::string GetTimezone() { #if FIREBASE_PLATFORM_WINDOWS // If "TZ" environment variable is defined, use it, else use _get_tzname. - int tz_chars = GetEnvironmentVariableW("TZ", nullptr, 0); + int tz_chars = GetEnvironmentVariableW(L"TZ", nullptr, 0); if (tz_chars > 0) { std::vector buffer(tz_chars + 1); - GetEnvironmentVariableW("TZ", &buffer[0], tz_chars); + GetEnvironmentVariableW(L"TZ", &buffer[0], tz_chars); std::wstring tz_utf16(&buffer[0]); std::wstring_convert, wchar_t> converter; return converter.to_bytes(wstring_string); From 3610b8581c483504b7634f8d8ecda87251d4f939 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 25 May 2023 12:36:44 -0700 Subject: [PATCH 03/38] Fix build error. --- app/src/locale.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index 64ac5672e7..e68f921b6f 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -99,7 +99,8 @@ std::string GetTimezone() { GetEnvironmentVariableW(L"TZ", &buffer[0], tz_chars); std::wstring tz_utf16(&buffer[0]); std::wstring_convert, wchar_t> converter; - return converter.to_bytes(wstring_string); + std::string tz_utf8 = converter.to_bytes(tz_utf16); + return tz_utf8; } int daylight; // daylight savings time? if (_get_daylight(&daylight) != 0) return ""; From a715c63e14369bc9ceeff1e9cc6699b83db8ece0 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 25 May 2023 13:11:52 -0700 Subject: [PATCH 04/38] Try a French time zone. --- .github/workflows/integration_tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 22daa2be7a..ff162adfd3 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -783,6 +783,7 @@ jobs: USE_FIRESTORE_EMULATOR: true shell: bash run: | + export TZ="Paris, Madrid (heure d'été)" if [[ "${{ needs.check_and_prepare.outputs.apis }}" == *"firestore"* ]]; then firebase emulators:exec --only firestore --project demo-example 'python scripts/gha/desktop_tester.py --testapp_dir testapps --logfile_name "desktop-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.ssl_variant }}"' else From d7a024970e0a898e1d3944356816b4020e3ed1b7 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 25 May 2023 13:14:26 -0700 Subject: [PATCH 05/38] Fix workflow. --- .github/workflows/integration_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index ff162adfd3..6c54e9210b 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -783,7 +783,7 @@ jobs: USE_FIRESTORE_EMULATOR: true shell: bash run: | - export TZ="Paris, Madrid (heure d'été)" + export TZ="Paris, Madrid (heure d\'été)" if [[ "${{ needs.check_and_prepare.outputs.apis }}" == *"firestore"* ]]; then firebase emulators:exec --only firestore --project demo-example 'python scripts/gha/desktop_tester.py --testapp_dir testapps --logfile_name "desktop-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.ssl_variant }}"' else From 697df16ce1f1b3261004815e9e597d982109a539 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 25 May 2023 13:15:47 -0700 Subject: [PATCH 06/38] Escape characters. --- .github/workflows/integration_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 6c54e9210b..719bc8d33a 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -783,7 +783,7 @@ jobs: USE_FIRESTORE_EMULATOR: true shell: bash run: | - export TZ="Paris, Madrid (heure d\'été)" + export TZ='Paris, Madrid \(heure d\'\ét\é\)' if [[ "${{ needs.check_and_prepare.outputs.apis }}" == *"firestore"* ]]; then firebase emulators:exec --only firestore --project demo-example 'python scripts/gha/desktop_tester.py --testapp_dir testapps --logfile_name "desktop-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.ssl_variant }}"' else From c76087f32fa6de912116587146e8610f0dc7978f Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 25 May 2023 13:17:44 -0700 Subject: [PATCH 07/38] Use GITHUB_ENV --- .github/workflows/integration_tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 719bc8d33a..58e0bb2289 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -778,12 +778,14 @@ jobs: with: distribution: 'temurin' java-version: '17' + - name: Set time zone + shell: bash + run: echo TZ='Paris, Madrid (heure d\'été\)' >> $GITHUB_ENV - name: Run Desktop integration tests env: USE_FIRESTORE_EMULATOR: true shell: bash run: | - export TZ='Paris, Madrid \(heure d\'\ét\é\)' if [[ "${{ needs.check_and_prepare.outputs.apis }}" == *"firestore"* ]]; then firebase emulators:exec --only firestore --project demo-example 'python scripts/gha/desktop_tester.py --testapp_dir testapps --logfile_name "desktop-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.ssl_variant }}"' else From 11cd846a24991bf555e02a249725c0048384193d Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 25 May 2023 13:29:31 -0700 Subject: [PATCH 08/38] Fix shell command. --- .github/workflows/integration_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 58e0bb2289..352ab7559d 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -780,7 +780,7 @@ jobs: java-version: '17' - name: Set time zone shell: bash - run: echo TZ='Paris, Madrid (heure d\'été\)' >> $GITHUB_ENV + run: echo TZ='Paris, Madrid (heure d'"'"'été)' >> $GITHUB_ENV - name: Run Desktop integration tests env: USE_FIRESTORE_EMULATOR: true From e327cfd3790058e2e8ecf35a93893a07400d5b14 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 25 May 2023 15:32:12 -0700 Subject: [PATCH 09/38] Change the approach, using tzset() instead. --- app/src/locale.cc | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index e68f921b6f..fb450da645 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -92,15 +92,11 @@ std::string GetLocale() { // Get the current time zone, e.g. "US/Pacific" std::string GetTimezone() { #if FIREBASE_PLATFORM_WINDOWS - // If "TZ" environment variable is defined, use it, else use _get_tzname. - int tz_chars = GetEnvironmentVariableW(L"TZ", nullptr, 0); - if (tz_chars > 0) { - std::vector buffer(tz_chars + 1); - GetEnvironmentVariableW(L"TZ", &buffer[0], tz_chars); - std::wstring tz_utf16(&buffer[0]); - std::wstring_convert, wchar_t> converter; - std::string tz_utf8 = converter.to_bytes(tz_utf16); - return tz_utf8; + static bool tz_was_set = false; + if (!tz_was_set) { + _tzset(); // Set the time zone used by the below functions, based on OS + // settings or the TZ variable, as appropriate. + tz_was_set = true; } int daylight; // daylight savings time? if (_get_daylight(&daylight) != 0) return ""; From 86ae73269bb36ccf388d07da16550f2642d5077d Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 25 May 2023 15:33:08 -0700 Subject: [PATCH 10/38] Logging. --- app/src/locale.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/locale.cc b/app/src/locale.cc index fb450da645..0c8de46dad 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -55,6 +55,7 @@ std::string GetLocale() { std::string output(woutput.begin(), woutput.end()); // Change all hyphens to underscores to normalize the locale. std::replace(output.begin(), output.end(), '-', '_'); + LogInfo("Locale: %s", output.c_str()); return output; #elif FIREBASE_PLATFORM_LINUX // If std::locale() has been customized, return it, else return the contents @@ -106,6 +107,7 @@ std::string GetTimezone() { if (_get_tzname(&length, &namebuf[0], length, daylight ? 1 : 0) != 0) return ""; std::string name_str(&namebuf[0]); + LogInfo("Time zone: %s", name_str.c_str()); return name_str; #elif FIREBASE_PLATFORM_LINUX // If TZ environment variable is defined and not empty, use it, else use From bda40f0dc0e5ab684df901eb42bd5707ac07d7ac Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 25 May 2023 15:40:00 -0700 Subject: [PATCH 11/38] Format code. --- app/src/locale.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index 0c8de46dad..d72a4b8575 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -96,7 +96,7 @@ std::string GetTimezone() { static bool tz_was_set = false; if (!tz_was_set) { _tzset(); // Set the time zone used by the below functions, based on OS - // settings or the TZ variable, as appropriate. + // settings or the TZ variable, as appropriate. tz_was_set = true; } int daylight; // daylight savings time? From 8536968fb7c3d14175783fdd46a5dfbc936f6083 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 25 May 2023 16:09:34 -0700 Subject: [PATCH 12/38] Set the time zone via tzutil. --- .github/workflows/integration_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 352ab7559d..0abc1971b6 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -779,8 +779,8 @@ jobs: distribution: 'temurin' java-version: '17' - name: Set time zone - shell: bash - run: echo TZ='Paris, Madrid (heure d'"'"'été)' >> $GITHUB_ENV + if: startsWith(matrix.os, 'windows') + run: tzutil /s "Paris, Madrid (heure d'été)" - name: Run Desktop integration tests env: USE_FIRESTORE_EMULATOR: true From a93ad4838d9a256d8b79f052a286159495757cd6 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 25 May 2023 17:00:49 -0700 Subject: [PATCH 13/38] List time zones available. --- .github/workflows/integration_tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 0abc1971b6..9f72c59ac6 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -780,7 +780,8 @@ jobs: java-version: '17' - name: Set time zone if: startsWith(matrix.os, 'windows') - run: tzutil /s "Paris, Madrid (heure d'été)" + run: tzutil /l + # "Paris, Madrid (heure d'été)" - name: Run Desktop integration tests env: USE_FIRESTORE_EMULATOR: true From 02102d03d9d60387f0d421d8ea547991b84bcfc5 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 25 May 2023 17:01:13 -0700 Subject: [PATCH 14/38] Remove comment. --- .github/workflows/integration_tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 9f72c59ac6..afc1159ba5 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -781,7 +781,6 @@ jobs: - name: Set time zone if: startsWith(matrix.os, 'windows') run: tzutil /l - # "Paris, Madrid (heure d'été)" - name: Run Desktop integration tests env: USE_FIRESTORE_EMULATOR: true From 4845994252a34452e71d12a41998e5a1b043b9bb Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 25 May 2023 17:20:58 -0700 Subject: [PATCH 15/38] Set to Paris time. --- .github/workflows/integration_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index afc1159ba5..3d6d8d50c6 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -780,7 +780,7 @@ jobs: java-version: '17' - name: Set time zone if: startsWith(matrix.os, 'windows') - run: tzutil /l + run: tzutil /s "Romance Daylight Time" - name: Run Desktop integration tests env: USE_FIRESTORE_EMULATOR: true From 9187cbcc8e8a159c5daa0ad7040d8497e1440651 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Fri, 26 May 2023 10:01:02 -0700 Subject: [PATCH 16/38] Fix test timezone. --- .github/workflows/integration_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 3d6d8d50c6..4d90837e48 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -780,7 +780,7 @@ jobs: java-version: '17' - name: Set time zone if: startsWith(matrix.os, 'windows') - run: tzutil /s "Romance Daylight Time" + run: tzutil /s "Romance Standard Time" - name: Run Desktop integration tests env: USE_FIRESTORE_EMULATOR: true From f7b6d660810c99101cb839d31d585950d704b4d3 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Fri, 26 May 2023 10:16:18 -0700 Subject: [PATCH 17/38] New method using ICL. --- app/src/locale.cc | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index d72a4b8575..3c15b4354f 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -26,6 +26,9 @@ #elif FIREBASE_PLATFORM_WINDOWS #include #include +// To convert Windows time zone names to IANA time zone names: +#define UCHAR_TYPE wchar_t +#include #elif FIREBASE_PLATFORM_LINUX #include #include @@ -107,8 +110,44 @@ std::string GetTimezone() { if (_get_tzname(&length, &namebuf[0], length, daylight ? 1 : 0) != 0) return ""; std::string name_str(&namebuf[0]); - LogInfo("Time zone: %s", name_str.c_str()); - return name_str; + LogInfo("Windows time zone: %s", name_str.c_str()); + std::wstring windows_time_zone_id(name_str); + + std::string locale_name = GetLocale(); + wchar_t iana_time_zone_buffer[128]; + UErrorCode error_status; + int32_t size; + bool got_time_zone = false; + if (locale_name.size() >= 5) { + // Try time zone first with the region code returned above, assuming it's at + // least 5 characters. For example, "en_US" -> "US" + std::string region_code = std::string(&locale_name[3], 2); + size = ucal_getTimeZoneIDForWindowsID(windows_time_zone_id.c_str(), -1, + region_code.c_str(), + iana_time_zone_buffer, + sizeof(iana_time_zone_buffer), + &error_status); + got_time_zone = (U_SUCCESS(error_code) && size > 0); + } + if (!got_time_zone) { + // Try without specifying a region + size = ucal_getTimeZoneIDForWindowsID(windows_time_zone_id.c_str(), -1, + nullptr, + iana_time_zone_buffer, + sizeof(iana_time_zone_buffer), + &error_status); + got_time_zone = (U_SUCCESS(error_code) && size > 0); + } + if (got_time_zone) { + std::wstring tz_utf16(iana_time_zone_buffer); + std::wstring_convert, wchar_t> converter; + return converter.to_bytes(tz_utf16); + } else { + // Couldn't convert to IANA + LogError("Couldn't convert time zone %s to IANA", name_str.c_str()); + return name_str; + } + #elif FIREBASE_PLATFORM_LINUX // If TZ environment variable is defined and not empty, use it, else use // tzname. From 26c381a85371d8f3bb6dfcccd93683b5f323c518 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Fri, 26 May 2023 18:20:15 -0700 Subject: [PATCH 18/38] Clean up string conversion. --- app/src/locale.cc | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index 3c15b4354f..873c1fb5e0 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -109,45 +109,52 @@ std::string GetTimezone() { std::vector namebuf(length); if (_get_tzname(&length, &namebuf[0], length, daylight ? 1 : 0) != 0) return ""; - std::string name_str(&namebuf[0]); - LogInfo("Windows time zone: %s", name_str.c_str()); - std::wstring windows_time_zone_id(name_str); + std::string windows_tz_utf8(&namebuf[0]); + LogInfo("Windows time zone: %s", windows_tz_utf8.c_str()); + + // Convert time zone name to wide string + std::wstring_convert> to_utf16; + std::wstring windows_tz_utf16 = to_utf16.from_bytes(windows_tz_utf8); std::string locale_name = GetLocale(); wchar_t iana_time_zone_buffer[128]; - UErrorCode error_status; + UErrorCode error_code; int32_t size; bool got_time_zone = false; if (locale_name.size() >= 5) { // Try time zone first with the region code returned above, assuming it's at // least 5 characters. For example, "en_US" -> "US" std::string region_code = std::string(&locale_name[3], 2); - size = ucal_getTimeZoneIDForWindowsID(windows_time_zone_id.c_str(), -1, - region_code.c_str(), - iana_time_zone_buffer, - sizeof(iana_time_zone_buffer), - &error_status); + size = ucal_getTimeZoneIDForWindowsID( + windows_tz_utf16.c_str(), -1, region_code.c_str(), + iana_time_zone_buffer, + sizeof(iana_time_zone_buffer) / sizeof(iana_time_zone_buffer[0]), + &error_code); got_time_zone = (U_SUCCESS(error_code) && size > 0); + if (!got_time_zone) { + LogWarning("Couldn't convert time zone %s with region %s to IANA: %d", + windows_tz_utf8.c_str(), region_code.c_str(), error_code); + } } if (!got_time_zone) { // Try without specifying a region - size = ucal_getTimeZoneIDForWindowsID(windows_time_zone_id.c_str(), -1, - nullptr, - iana_time_zone_buffer, - sizeof(iana_time_zone_buffer), - &error_status); + size = ucal_getTimeZoneIDForWindowsID( + windows_tz_utf16.c_str(), -1, nullptr, iana_time_zone_buffer, + sizeof(iana_time_zone_buffer) / sizeof(iana_time_zone_buffer[0]), + &error_code); got_time_zone = (U_SUCCESS(error_code) && size > 0); } if (got_time_zone) { - std::wstring tz_utf16(iana_time_zone_buffer); - std::wstring_convert, wchar_t> converter; - return converter.to_bytes(tz_utf16); + std::wstring iana_tz_utf16(iana_time_zone_buffer); + std::wstring_convert, wchar_t> to_utf8; + return to_utf8.to_bytes(tz_utf16); } else { // Couldn't convert to IANA - LogError("Couldn't convert time zone %s to IANA", name_str.c_str()); + LogError("Couldn't convert time zone %s to IANA: %d", name_str.c_str(), + error_code); return name_str; } - + #elif FIREBASE_PLATFORM_LINUX // If TZ environment variable is defined and not empty, use it, else use // tzname. From 95e1a03c380f2be89b3af8c434df3713fa72ca13 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Fri, 26 May 2023 18:25:19 -0700 Subject: [PATCH 19/38] Clean up log. --- app/src/locale.cc | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index 873c1fb5e0..adeddce4ce 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -132,8 +132,10 @@ std::string GetTimezone() { &error_code); got_time_zone = (U_SUCCESS(error_code) && size > 0); if (!got_time_zone) { - LogWarning("Couldn't convert time zone %s with region %s to IANA: %d", - windows_tz_utf8.c_str(), region_code.c_str(), error_code); + LogWarning( + "Couldn't convert Windows time zone '%s' with region '%s' to IANA: " + "%d", + windows_tz_utf8.c_str(), region_code.c_str(), error_code); } } if (!got_time_zone) { @@ -143,18 +145,23 @@ std::string GetTimezone() { sizeof(iana_time_zone_buffer) / sizeof(iana_time_zone_buffer[0]), &error_code); got_time_zone = (U_SUCCESS(error_code) && size > 0); + if (!got_time_zone) { + // Couldn't convert to IANA + LogError("Couldn't convert time zone '%s' to IANA: %d", + windows_tz_utf8.c_str(), error_code); + } } - if (got_time_zone) { - std::wstring iana_tz_utf16(iana_time_zone_buffer); - std::wstring_convert, wchar_t> to_utf8; - return to_utf8.to_bytes(tz_utf16); - } else { - // Couldn't convert to IANA - LogError("Couldn't convert time zone %s to IANA: %d", name_str.c_str(), - error_code); - return name_str; + if (!got_time_zone) { + // Return the Windows time zone ID as a backup. + return windows_tz_utf8; } + std::wstring iana_tz_utf16(iana_time_zone_buffer); + std::wstring_convert, wchar_t> to_utf8; + std::string iana_tz_utf8 = to_utf8.to_bytes(tz_utf16); + LogInfo("IANA time zone: %s", iana_tz_utf8.c_str()); + return iana_tz_utf8; + #elif FIREBASE_PLATFORM_LINUX // If TZ environment variable is defined and not empty, use it, else use // tzname. From 75b3209ad5ba8f5077b3f20046a794a97b2fcd28 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Sat, 27 May 2023 00:01:12 -0700 Subject: [PATCH 20/38] Fix compile error. --- app/src/locale.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index adeddce4ce..c60dede8e9 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -158,7 +158,7 @@ std::string GetTimezone() { std::wstring iana_tz_utf16(iana_time_zone_buffer); std::wstring_convert, wchar_t> to_utf8; - std::string iana_tz_utf8 = to_utf8.to_bytes(tz_utf16); + std::string iana_tz_utf8 = to_utf8.to_bytes(iana_tz_utf16); LogInfo("IANA time zone: %s", iana_tz_utf8.c_str()); return iana_tz_utf8; From ace40f03d530f7a60cd7d7f131ed5f1c59ccc732 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Sat, 27 May 2023 00:12:19 -0700 Subject: [PATCH 21/38] Add ICU DLL. --- remote_config/integration_test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote_config/integration_test/CMakeLists.txt b/remote_config/integration_test/CMakeLists.txt index 3b61f6f729..6e99d6836e 100644 --- a/remote_config/integration_test/CMakeLists.txt +++ b/remote_config/integration_test/CMakeLists.txt @@ -209,7 +209,7 @@ else() "-framework Security" ) elseif(MSVC) - set(ADDITIONAL_LIBS advapi32 ws2_32 crypt32) + set(ADDITIONAL_LIBS advapi32 ws2_32 crypt32 icu) else() set(ADDITIONAL_LIBS pthread) endif() From bc81b27819fb564450d4ab59a6056f25ce919492 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Sat, 27 May 2023 09:10:20 -0700 Subject: [PATCH 22/38] Fix log; test France. --- app/src/locale.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index c60dede8e9..d58299b437 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -124,7 +124,7 @@ std::string GetTimezone() { if (locale_name.size() >= 5) { // Try time zone first with the region code returned above, assuming it's at // least 5 characters. For example, "en_US" -> "US" - std::string region_code = std::string(&locale_name[3], 2); + std::string region_code = "FR"; // std::string(&locale_name[3], 2); size = ucal_getTimeZoneIDForWindowsID( windows_tz_utf16.c_str(), -1, region_code.c_str(), iana_time_zone_buffer, @@ -134,8 +134,8 @@ std::string GetTimezone() { if (!got_time_zone) { LogWarning( "Couldn't convert Windows time zone '%s' with region '%s' to IANA: " - "%d", - windows_tz_utf8.c_str(), region_code.c_str(), error_code); + "%s (%d)", + windows_tz_utf8.c_str(), region_code.c_str(), u_errorName(error_code), error_code); } } if (!got_time_zone) { @@ -147,8 +147,8 @@ std::string GetTimezone() { got_time_zone = (U_SUCCESS(error_code) && size > 0); if (!got_time_zone) { // Couldn't convert to IANA - LogError("Couldn't convert time zone '%s' to IANA: %d", - windows_tz_utf8.c_str(), error_code); + LogError("Couldn't convert time zone '%s' to IANA: %s (%d)", + windows_tz_utf8.c_str(), u_errorName(error_code), error_code); } } if (!got_time_zone) { From bde33b09b24fd573caa95f99710c3688e320bd54 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Sun, 28 May 2023 00:39:58 -0700 Subject: [PATCH 23/38] Initialize variables. --- app/src/locale.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index d58299b437..97e3a6dbea 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -118,10 +118,11 @@ std::string GetTimezone() { std::string locale_name = GetLocale(); wchar_t iana_time_zone_buffer[128]; - UErrorCode error_code; - int32_t size; bool got_time_zone = false; if (locale_name.size() >= 5) { + wcscpy(iana_time_zone_buffer, L""); + UErrorCode error_code = 0; + int32_t size = 0; // Try time zone first with the region code returned above, assuming it's at // least 5 characters. For example, "en_US" -> "US" std::string region_code = "FR"; // std::string(&locale_name[3], 2); @@ -134,11 +135,14 @@ std::string GetTimezone() { if (!got_time_zone) { LogWarning( "Couldn't convert Windows time zone '%s' with region '%s' to IANA: " - "%s (%d)", + "%s (%x)", windows_tz_utf8.c_str(), region_code.c_str(), u_errorName(error_code), error_code); } } if (!got_time_zone) { + wcscpy(iana_time_zone_buffer, L""); + UErrorCode error_code = 0; + int32_t size = 0; // Try without specifying a region size = ucal_getTimeZoneIDForWindowsID( windows_tz_utf16.c_str(), -1, nullptr, iana_time_zone_buffer, @@ -147,14 +151,16 @@ std::string GetTimezone() { got_time_zone = (U_SUCCESS(error_code) && size > 0); if (!got_time_zone) { // Couldn't convert to IANA - LogError("Couldn't convert time zone '%s' to IANA: %s (%d)", + LogError("Couldn't convert time zone '%s' to IANA: %s (%x)", windows_tz_utf8.c_str(), u_errorName(error_code), error_code); } } + /* if (!got_time_zone) { // Return the Windows time zone ID as a backup. return windows_tz_utf8; } + */ std::wstring iana_tz_utf16(iana_time_zone_buffer); std::wstring_convert, wchar_t> to_utf8; From 48aed5956e73ae0d42c033ac997044e8688d3f9d Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Sun, 28 May 2023 01:47:17 -0700 Subject: [PATCH 24/38] Cast --- app/src/locale.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index 97e3a6dbea..c511290a49 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -121,7 +121,7 @@ std::string GetTimezone() { bool got_time_zone = false; if (locale_name.size() >= 5) { wcscpy(iana_time_zone_buffer, L""); - UErrorCode error_code = 0; + UErrorCode error_code = (UErrorCode)0; int32_t size = 0; // Try time zone first with the region code returned above, assuming it's at // least 5 characters. For example, "en_US" -> "US" @@ -141,7 +141,7 @@ std::string GetTimezone() { } if (!got_time_zone) { wcscpy(iana_time_zone_buffer, L""); - UErrorCode error_code = 0; + UErrorCode error_code = (UErrorCode)0; int32_t size = 0; // Try without specifying a region size = ucal_getTimeZoneIDForWindowsID( From dd2aafa63685a6e2b82a627a2bb6b9eafcfe3184 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Sun, 28 May 2023 12:40:56 -0700 Subject: [PATCH 25/38] Don't get the daylight zone. --- app/src/locale.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index c511290a49..af9f27b856 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -105,7 +105,8 @@ std::string GetTimezone() { int daylight; // daylight savings time? if (_get_daylight(&daylight) != 0) return ""; size_t length = 0; // get the needed string length - if (_get_tzname(&length, nullptr, 0, daylight ? 1 : 0) != 0) return ""; + //if (_get_tzname(&length, nullptr, 0, daylight ? 1 : 0) != 0) return ""; + if (_get_tzname(&length, nullptr, /* daylight = */ 0, 1) != 0) return ""; std::vector namebuf(length); if (_get_tzname(&length, &namebuf[0], length, daylight ? 1 : 0) != 0) return ""; From 8a7c7fed2ac996fb3bedd7916d099babc410b892 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Sun, 28 May 2023 14:07:42 -0700 Subject: [PATCH 26/38] Fix --- app/src/locale.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index af9f27b856..f24e3a3a37 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -106,7 +106,7 @@ std::string GetTimezone() { if (_get_daylight(&daylight) != 0) return ""; size_t length = 0; // get the needed string length //if (_get_tzname(&length, nullptr, 0, daylight ? 1 : 0) != 0) return ""; - if (_get_tzname(&length, nullptr, /* daylight = */ 0, 1) != 0) return ""; + if (_get_tzname(&length, nullptr, 0, /* daylight = */ 0) != 0) return ""; std::vector namebuf(length); if (_get_tzname(&length, &namebuf[0], length, daylight ? 1 : 0) != 0) return ""; From e5da42479c833e1f0d06efc98fbf5f9af5686c19 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Sun, 28 May 2023 19:14:14 -0700 Subject: [PATCH 27/38] Fix 2 --- app/src/locale.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index f24e3a3a37..6c3a6b4097 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -106,9 +106,9 @@ std::string GetTimezone() { if (_get_daylight(&daylight) != 0) return ""; size_t length = 0; // get the needed string length //if (_get_tzname(&length, nullptr, 0, daylight ? 1 : 0) != 0) return ""; - if (_get_tzname(&length, nullptr, 0, /* daylight = */ 0) != 0) return ""; + if (_get_tzname(&length, nullptr, 0, 0) != 0) return ""; std::vector namebuf(length); - if (_get_tzname(&length, &namebuf[0], length, daylight ? 1 : 0) != 0) + if (_get_tzname(&length, &namebuf[0], length, 0) != 0) return ""; std::string windows_tz_utf8(&namebuf[0]); LogInfo("Windows time zone: %s", windows_tz_utf8.c_str()); From 097466b15c54327c0eec36db5d43851e1599eb0c Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Sun, 28 May 2023 21:55:09 -0700 Subject: [PATCH 28/38] Fix daylight mode fallback. --- app/src/locale.cc | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index 6c3a6b4097..2fdb4bce65 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -102,15 +102,15 @@ std::string GetTimezone() { // settings or the TZ variable, as appropriate. tz_was_set = true; } - int daylight; // daylight savings time? - if (_get_daylight(&daylight) != 0) return ""; - size_t length = 0; // get the needed string length - //if (_get_tzname(&length, nullptr, 0, daylight ? 1 : 0) != 0) return ""; - if (_get_tzname(&length, nullptr, 0, 0) != 0) return ""; - std::vector namebuf(length); - if (_get_tzname(&length, &namebuf[0], length, 0) != 0) - return ""; - std::string windows_tz_utf8(&namebuf[0]); + // Get the standard time zone name. + std::string windows_tz_utf8; + { + size_t length = 0; // get the needed string length + if (_get_tzname(&length, nullptr, 0, 0) != 0) return ""; + std::vector namebuf(length); + if (_get_tzname(&length, &namebuf[0], length, 0) != 0) return ""; + windows_tz_utf8 = std::string(&namebuf[0]); + } LogInfo("Windows time zone: %s", windows_tz_utf8.c_str()); // Convert time zone name to wide string @@ -126,7 +126,7 @@ std::string GetTimezone() { int32_t size = 0; // Try time zone first with the region code returned above, assuming it's at // least 5 characters. For example, "en_US" -> "US" - std::string region_code = "FR"; // std::string(&locale_name[3], 2); + std::string region_code = "FR"; // std::string(&locale_name[3], 2); size = ucal_getTimeZoneIDForWindowsID( windows_tz_utf16.c_str(), -1, region_code.c_str(), iana_time_zone_buffer, @@ -137,7 +137,8 @@ std::string GetTimezone() { LogWarning( "Couldn't convert Windows time zone '%s' with region '%s' to IANA: " "%s (%x)", - windows_tz_utf8.c_str(), region_code.c_str(), u_errorName(error_code), error_code); + windows_tz_utf8.c_str(), region_code.c_str(), u_errorName(error_code), + error_code); } } if (!got_time_zone) { @@ -156,12 +157,22 @@ std::string GetTimezone() { windows_tz_utf8.c_str(), u_errorName(error_code), error_code); } } - /* if (!got_time_zone) { // Return the Windows time zone ID as a backup. + // In this case, we need to get the correct daylight savings time + // setting to get the right name. + int daylight = 0; // daylight savings time? + if (_get_daylight(&daylight) != 0) return windows_tz_utf8; + if (daylight) { + size_t length = 0; // get the needed string length + if (_get_tzname(&length, nullptr, 0, 1) != 0) return windows_tz_utf8; + std::vector namebuf(length); + if (_get_tzname(&length, &namebuf[0], length, 1) != 0) + return windows_tz_utf8; + windows_tz_utf8 = std::string(&namebuf[0]); + } return windows_tz_utf8; } - */ std::wstring iana_tz_utf16(iana_time_zone_buffer); std::wstring_convert, wchar_t> to_utf8; From f52f75d1748c003fb5f30bc50e7945ac078a55ac Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Sun, 28 May 2023 21:55:58 -0700 Subject: [PATCH 29/38] Remove French language test code. --- .github/workflows/integration_tests.yml | 3 --- app/src/locale.cc | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 4d90837e48..22daa2be7a 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -778,9 +778,6 @@ jobs: with: distribution: 'temurin' java-version: '17' - - name: Set time zone - if: startsWith(matrix.os, 'windows') - run: tzutil /s "Romance Standard Time" - name: Run Desktop integration tests env: USE_FIRESTORE_EMULATOR: true diff --git a/app/src/locale.cc b/app/src/locale.cc index 2fdb4bce65..dd149fa7b7 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -126,7 +126,7 @@ std::string GetTimezone() { int32_t size = 0; // Try time zone first with the region code returned above, assuming it's at // least 5 characters. For example, "en_US" -> "US" - std::string region_code = "FR"; // std::string(&locale_name[3], 2); + std::string region_code = std::string(&locale_name[3], 2); size = ucal_getTimeZoneIDForWindowsID( windows_tz_utf16.c_str(), -1, region_code.c_str(), iana_time_zone_buffer, From 149c9c55cdc0cda4cccb418cb5852f4a8804ce79 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 31 May 2023 11:41:36 -0700 Subject: [PATCH 30/38] Change log messages to debug. --- app/src/locale.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index dd149fa7b7..89918bc893 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -58,7 +58,7 @@ std::string GetLocale() { std::string output(woutput.begin(), woutput.end()); // Change all hyphens to underscores to normalize the locale. std::replace(output.begin(), output.end(), '-', '_'); - LogInfo("Locale: %s", output.c_str()); + LogDebug("Locale: %s", output.c_str()); return output; #elif FIREBASE_PLATFORM_LINUX // If std::locale() has been customized, return it, else return the contents @@ -111,7 +111,7 @@ std::string GetTimezone() { if (_get_tzname(&length, &namebuf[0], length, 0) != 0) return ""; windows_tz_utf8 = std::string(&namebuf[0]); } - LogInfo("Windows time zone: %s", windows_tz_utf8.c_str()); + LogDebug("Windows time zone: %s", windows_tz_utf8.c_str()); // Convert time zone name to wide string std::wstring_convert> to_utf16; @@ -177,7 +177,7 @@ std::string GetTimezone() { std::wstring iana_tz_utf16(iana_time_zone_buffer); std::wstring_convert, wchar_t> to_utf8; std::string iana_tz_utf8 = to_utf8.to_bytes(iana_tz_utf16); - LogInfo("IANA time zone: %s", iana_tz_utf8.c_str()); + LogDebug("IANA time zone: %s", iana_tz_utf8.c_str()); return iana_tz_utf8; #elif FIREBASE_PLATFORM_LINUX From 58c6ac25350570c88c81694002b230e424855810 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 31 May 2023 11:44:48 -0700 Subject: [PATCH 31/38] Change errors. --- app/src/locale.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index 89918bc893..2f2963c2a2 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -134,9 +134,9 @@ std::string GetTimezone() { &error_code); got_time_zone = (U_SUCCESS(error_code) && size > 0); if (!got_time_zone) { - LogWarning( + LogDebug( "Couldn't convert Windows time zone '%s' with region '%s' to IANA: " - "%s (%x)", + "%s (%x). Falling back to non-region time zone conversion.", windows_tz_utf8.c_str(), region_code.c_str(), u_errorName(error_code), error_code); } @@ -153,8 +153,10 @@ std::string GetTimezone() { got_time_zone = (U_SUCCESS(error_code) && size > 0); if (!got_time_zone) { // Couldn't convert to IANA - LogError("Couldn't convert time zone '%s' to IANA: %s (%x)", - windows_tz_utf8.c_str(), u_errorName(error_code), error_code); + LogDebug( + "Couldn't convert time zone '%s' to IANA: %s (%x). Falling back to " + "Windows time zone name.", + windows_tz_utf8.c_str(), u_errorName(error_code), error_code); } } if (!got_time_zone) { From 55792c5bed2f059764bc916e4ded1f420d960bf9 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 31 May 2023 12:15:22 -0700 Subject: [PATCH 32/38] Add icu.dll to library dependencies. --- remote_config/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/remote_config/CMakeLists.txt b/remote_config/CMakeLists.txt index 906a129e91..624f28a8b5 100644 --- a/remote_config/CMakeLists.txt +++ b/remote_config/CMakeLists.txt @@ -107,6 +107,11 @@ else() ${PROJECT_BINARY_DIR}/..) set(additional_link_LIB firebase_rest_lib) + if(MSVC) + # Remote Config on Windows requires the icu.dll system library for time zone + # handling. + set(additional_link_LIB ${additional_link_LIB} icu) + endif() endif() add_library(firebase_remote_config STATIC From df16b68d353030a52a74a1c6f3ab36508e7fa48e Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 31 May 2023 12:26:59 -0700 Subject: [PATCH 33/38] Update release notes. --- release_build_files/readme.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/release_build_files/readme.md b/release_build_files/readme.md index 702bcf6dc0..64fe7eb564 100644 --- a/release_build_files/readme.md +++ b/release_build_files/readme.md @@ -483,7 +483,7 @@ App Check | `advapi32, ws2_32, crypt32` Firestore | `advapi32, ws2_32, crypt32, rpcrt4, ole32, shell32, dbghelp, bcrypt` Functions | `advapi32, ws2_32, crypt32, rpcrt4, ole32` Realtime Database | `advapi32, ws2_32, crypt32, iphlpapi, psapi, userenv, shell32` -Remote Config | `advapi32, ws2_32, crypt32, rpcrt4, ole32` +Remote Config | `advapi32, ws2_32, crypt32, rpcrt4, ole32, icu` Storage | `advapi32, ws2_32, crypt32` ## Getting Started @@ -627,6 +627,13 @@ workflow use only during the development of your app, not for publicly shipping code. ## Release Notes +### 11.2.0 +- Changes + - Remote Config (Desktop): Fixed handling of time zones on Windows to work + regardless of system language. This adds a requirement for applications + using Remote Config on Windows desktop to link the "icu.dll" system + library. + ### 11.1.0 - Changes - General (Android): Update to Firebase Android BoM version 32.1.0. From decdce8e11b5cda953011d1e47bbd530c0b3f646 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 31 May 2023 12:29:03 -0700 Subject: [PATCH 34/38] Remove version number --- release_build_files/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_build_files/readme.md b/release_build_files/readme.md index 64fe7eb564..db30ae4828 100644 --- a/release_build_files/readme.md +++ b/release_build_files/readme.md @@ -627,7 +627,7 @@ workflow use only during the development of your app, not for publicly shipping code. ## Release Notes -### 11.2.0 +### Upcoming Release - Changes - Remote Config (Desktop): Fixed handling of time zones on Windows to work regardless of system language. This adds a requirement for applications From 23f9bd774cf5e67e1209da7420b84100d899b10a Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 31 May 2023 17:00:12 -0700 Subject: [PATCH 35/38] Added icu.dll dep to locale unit test. --- app/tests/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/tests/CMakeLists.txt b/app/tests/CMakeLists.txt index eaa8c80676..6eb3d1bd82 100644 --- a/app/tests/CMakeLists.txt +++ b/app/tests/CMakeLists.txt @@ -207,11 +207,17 @@ firebase_cpp_cc_test(firebase_app_path_test firebase_app ) +if (MSVC) + set(LOCALE_TEST_DEPS icu) +else() + set(LOCALE_TEST_DEPS) +endif() + firebase_cpp_cc_test(firebase_app_locale_test SOURCES locale_test.cc DEPENDS - firebase_app + firebase_app ${LOCALE_TEST_DEPS} ) firebase_cpp_cc_test(firebase_app_callback_test From bc1bb5fe36f2beac4ce863945fc09cf4dc61acbc Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 1 Jun 2023 10:47:44 -0700 Subject: [PATCH 36/38] Update release note. --- release_build_files/readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/release_build_files/readme.md b/release_build_files/readme.md index db30ae4828..9d8fd15df6 100644 --- a/release_build_files/readme.md +++ b/release_build_files/readme.md @@ -629,10 +629,10 @@ code. ## Release Notes ### Upcoming Release - Changes - - Remote Config (Desktop): Fixed handling of time zones on Windows to work - regardless of system language. This adds a requirement for applications - using Remote Config on Windows desktop to link the "icu.dll" system - library. + - Remote Config (Desktop): Fixed handling of time zones on Windows when the + time zone name in the current system language contains an accented + character or apostrophe. This adds a requirement for applications using + Remote Config on Windows desktop to link the "icu.dll" system library. ### 11.1.0 - Changes From 66ca4a1e004349ac1ffb22a33e56e119786c943e Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 1 Jun 2023 15:44:25 -0700 Subject: [PATCH 37/38] Remove extraneous printfs. --- app/src/locale.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/locale.cc b/app/src/locale.cc index 2f2963c2a2..77e1b80db2 100644 --- a/app/src/locale.cc +++ b/app/src/locale.cc @@ -58,7 +58,6 @@ std::string GetLocale() { std::string output(woutput.begin(), woutput.end()); // Change all hyphens to underscores to normalize the locale. std::replace(output.begin(), output.end(), '-', '_'); - LogDebug("Locale: %s", output.c_str()); return output; #elif FIREBASE_PLATFORM_LINUX // If std::locale() has been customized, return it, else return the contents @@ -111,7 +110,6 @@ std::string GetTimezone() { if (_get_tzname(&length, &namebuf[0], length, 0) != 0) return ""; windows_tz_utf8 = std::string(&namebuf[0]); } - LogDebug("Windows time zone: %s", windows_tz_utf8.c_str()); // Convert time zone name to wide string std::wstring_convert> to_utf16; @@ -179,7 +177,6 @@ std::string GetTimezone() { std::wstring iana_tz_utf16(iana_time_zone_buffer); std::wstring_convert, wchar_t> to_utf8; std::string iana_tz_utf8 = to_utf8.to_bytes(iana_tz_utf16); - LogDebug("IANA time zone: %s", iana_tz_utf8.c_str()); return iana_tz_utf8; #elif FIREBASE_PLATFORM_LINUX From ebb0510d99c3659fa525bbd5278cb66f3225cf64 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 1 Jun 2023 15:46:26 -0700 Subject: [PATCH 38/38] Add comment to test cmake. --- app/tests/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/tests/CMakeLists.txt b/app/tests/CMakeLists.txt index 6eb3d1bd82..f6c1ec5eff 100644 --- a/app/tests/CMakeLists.txt +++ b/app/tests/CMakeLists.txt @@ -208,6 +208,8 @@ firebase_cpp_cc_test(firebase_app_path_test ) if (MSVC) + # On Windows, our locale library's GetTimezone() function requires the icu.dll + # system library for converting from Windows time zones to IANA time zones. set(LOCALE_TEST_DEPS icu) else() set(LOCALE_TEST_DEPS)