aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authord-dima <d-dima@yandex-team.com>2024-03-12 14:21:35 +0300
committerd-dima <d-dima@yandex-team.com>2024-03-12 14:41:41 +0300
commite98c636d759bf6f106a2b90142041bb9d4f1e33f (patch)
treee100425e8bbdf4bec72855b41ee7ea37a2d392ec /library/cpp
parente8fb59b11b5486102d179d32155d304b45c26562 (diff)
downloadydb-e98c636d759bf6f106a2b90142041bb9d4f1e33f.tar.gz
Make "GMT+03:00" known timezone format
cd2e9b766cd6579b0124ffe05b23a22513e19a93
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/timezone_conversion/civil.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/library/cpp/timezone_conversion/civil.cpp b/library/cpp/timezone_conversion/civil.cpp
index 0a9b6acaa6..fe8d10bfc5 100644
--- a/library/cpp/timezone_conversion/civil.cpp
+++ b/library/cpp/timezone_conversion/civil.cpp
@@ -20,10 +20,15 @@ namespace {
return true;
}
- bool TryParseUTCOffsetTimezone(TStringBuf name, int& offset) {
- static constexpr TStringBuf OFFSET_PREFIX = "UTC";
- if (!name.SkipPrefix(OFFSET_PREFIX)) {
- return false;
+ bool TryParseUTCGMTOffsetTimezone(TStringBuf name, int& offset) {
+ static constexpr TStringBuf OFFSET_PREFIX_UTC = "UTC";
+ static constexpr TStringBuf OFFSET_PREFIX_GMT = "GMT";
+ if (!name.SkipPrefix(OFFSET_PREFIX_UTC)) {
+ // Sometimes timezones from client devices look like 'GMT+03:00'
+ // This format is not standard but can be translated like UTC+xxx
+ if (!name.SkipPrefix(OFFSET_PREFIX_GMT)) {
+ return false;
+ }
}
return NDatetime::TryParseOffset(name, offset);
}
@@ -70,7 +75,11 @@ namespace NDatetime {
TTimeZone GetTimeZone(TStringBuf name) {
int offset;
- if (TryParseUTCOffsetTimezone(name, offset)) {
+ // Try to preparse constant timezones like:
+ // UTC+03:00
+ // GMT+03:00
+ // Note constant timezones like 'Etc-03' will be handed in cctz library
+ if (TryParseUTCGMTOffsetTimezone(name, offset)) {
return GetFixedTimeZone(offset);
}
TTimeZone result;