From b3bc56c30ee55d8ad32ae6f86de51c21336f1151 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 16 Jun 2017 11:08:39 +0200 Subject: EDI TIST: Add local file cache for leap second data --- src/ClockTAI.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/ClockTAI.h') diff --git a/src/ClockTAI.h b/src/ClockTAI.h index ab70384..99827ba 100644 --- a/src/ClockTAI.h +++ b/src/ClockTAI.h @@ -59,7 +59,10 @@ class ClockTAI { #endif private: - int download_offset_task(void); + // Either retrieve the bulletin from the cache or if necessarly + // download it, and calculate the TAI-UTC offset. + // Returns the offset. + int get_valid_offset(void); // Download of new bulletin is done asynchronously std::future m_offset_future; @@ -71,7 +74,17 @@ class ClockTAI { std::stringstream m_bulletin; std::chrono::system_clock::time_point m_bulletin_download_time; - // Load bulletin into m_bulletin + // Load bulletin into m_bulletin from the cache file + void load_bulletin_from_file(const char* cache_filename); + + // Update the cache file with the current m_bulletin + void update_cache(const char* cache_filename); + + // Verifies the expiration date in the m_bulletin. Returns + // true if the bulletin is valid. + bool bulletin_is_valid(void); + + // Load bulletin into m_bulletin from the URL void download_tai_utc_bulletin(const char* url); // read TAI offset from m_bulletin in IETF format -- cgit v1.2.3