aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-02-19 15:55:08 +0100
committerMattias Andrée <maandree@kth.se>2021-02-19 15:55:08 +0100
commit3afa34e8db077e7d771e61f9cdc59dcd6e0a7c8a (patch)
treee95b58194bcf96009729e6484ed96b125b58c898
parentUpdate documentation (diff)
downloadmongoclock-3afa34e8db077e7d771e61f9cdc59dcd6e0a7c8a.tar.gz
mongoclock-3afa34e8db077e7d771e61f9cdc59dcd6e0a7c8a.tar.bz2
mongoclock-3afa34e8db077e7d771e61f9cdc59dcd6e0a7c8a.tar.xz
Fix leap second support3.1.1
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--mongoclock.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/mongoclock.c b/mongoclock.c
index 3823b13..dfc5578 100644
--- a/mongoclock.c
+++ b/mongoclock.c
@@ -135,11 +135,29 @@ display_time(int timerfd)
r = adjtimex(&timex);
if (r == -1)
goto fail;
- now = localtime(&timex.time.tv_sec);
- if (now == NULL)
- goto fail;
- if (r == TIME_OOP)
+ if (timex.time.tv_sec % (24 * 60 * 60) == 0) {
+ if (r == TIME_INS) {
+ timex.time.tv_sec -= 1;
+ now = localtime(&timex.time.tv_sec);
+ if (!now)
+ goto fail;
+ now->tm_sec += 1;
+ goto now_checked;
+ } else if (r == TIME_DEL) {
+ timex.time.tv_sec += 1;
+ now = localtime(&timex.time.tv_sec);
+ } else {
+ now = localtime(&timex.time.tv_sec);
+ }
+ } else if (r == TIME_OOP) {
+ now = localtime(&timex.time.tv_sec);
now->tm_sec += 1;
+ } else {
+ now = localtime(&timex.time.tv_sec);
+ }
+ if (!now)
+ goto fail;
+ now_checked:
#else
now_ = time(NULL);
if (now_ == -1)