diff options
Diffstat (limited to 'src/mongo/db/query/datetime')
-rw-r--r-- | src/mongo/db/query/datetime/date_time_support.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/query/datetime/date_time_support.h | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/db/query/datetime/date_time_support.cpp b/src/mongo/db/query/datetime/date_time_support.cpp index 199a3100453..a0c56878a89 100644 --- a/src/mongo/db/query/datetime/date_time_support.cpp +++ b/src/mongo/db/query/datetime/date_time_support.cpp @@ -347,6 +347,11 @@ boost::optional<Seconds> TimeZoneDatabase::parseUtcOffset(StringData offsetSpec) return boost::none; } +bool TimeZoneDatabase::isTimeZoneIdentifier(StringData timeZoneId) const { + return (_timeZones.find(timeZoneId) != _timeZones.end()) || + static_cast<bool>(parseUtcOffset(timeZoneId)); +} + TimeZone TimeZoneDatabase::getTimeZone(StringData timeZoneId) const { auto tz = _timeZones.find(timeZoneId); if (tz != _timeZones.end()) { diff --git a/src/mongo/db/query/datetime/date_time_support.h b/src/mongo/db/query/datetime/date_time_support.h index 8035c9239d5..a97a2f4b5fd 100644 --- a/src/mongo/db/query/datetime/date_time_support.h +++ b/src/mongo/db/query/datetime/date_time_support.h @@ -421,6 +421,11 @@ public: static TimeZone utcZone(); /** + * Returns a boolean based on if 'timeZoneId' represents a valid timezone. + */ + bool isTimeZoneIdentifier(StringData timeZoneId) const; + + /** * Returns a TimeZone object representing the zone given by 'timeZoneId', or boost::none if it * was not a recognized time zone. */ |