From f2fc875d9dbac49fbc71dab88996e8e0a14d8b6a Mon Sep 17 00:00:00 2001 From: Chris Frey Date: Thu, 15 Mar 2012 11:47:29 -0400 Subject: [PATCH] lib: added static TimeZones::IsLoadable() Not all devices have a Time Zones database. This static function allows the application to determine in advance which table to load. --- src/r_timezone.cc | 6 ++++++ src/r_timezone.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/r_timezone.cc b/src/r_timezone.cc index 543956c3..c9920d63 100644 --- a/src/r_timezone.cc +++ b/src/r_timezone.cc @@ -411,6 +411,12 @@ TimeZones::TimeZones(Barry::Mode::Desktop &desktop) sort(begin(), end(), &TimeZone::SortByZone); } +bool TimeZones::IsLoadable(Barry::Mode::Desktop &desktop) +{ + unsigned int num; + return desktop.GetDBDB().GetDBNumber(TimeZone::GetDBName(), num); +} + TimeZones::iterator TimeZones::Find(int index) { for( iterator i = begin(), e = end(); i != e; ++i ) diff --git a/src/r_timezone.h b/src/r_timezone.h index 782fa956..204611c7 100644 --- a/src/r_timezone.h +++ b/src/r_timezone.h @@ -189,6 +189,10 @@ public: /// Extracts the time zone database from the given device. explicit TimeZones(Barry::Mode::Desktop &desktop); + /// Static helper function that returns true if the device + /// referenced by desktop has a time zone database + static bool IsLoadable(Barry::Mode::Desktop &desktop); + ListType& GetList() { return m_list; } const ListType& GetList() const { return m_list; } -- 2.11.4.GIT