Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

Commit

Permalink
Fix registering the DST or leap second announcement in case the progr…
Browse files Browse the repository at this point in the history
…am is started after half the hour.

Use the number of correctly received minutes in this hour instead of the
current minute value to compare the number of correctly received
announcements against.

Issue #31
  • Loading branch information
Rene Ladan committed Mar 25, 2018
1 parent f8cdb12 commit 25d5832
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions decode_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <string.h>
#include <time.h>

static int dst_count, leap_count;
static int dst_count, leap_count, minute_count;
static struct DT_result dt_res;

static bool
Expand Down Expand Up @@ -227,7 +227,7 @@ handle_leap_second(unsigned errflags, int minlen, const int buffer[],
if (buffer[19] == 1 && errflags == 0)
leap_count++;
if (time.tm_min > 0)
dt_res.leap_announce = 2 * leap_count > time.tm_min;
dt_res.leap_announce = 2 * leap_count > minute_count;

/* process possible leap second */
if (dt_res.leap_announce && time.tm_min == 0) {
Expand Down Expand Up @@ -263,7 +263,7 @@ handle_dst(unsigned errflags, bool olderr, const int buffer[], struct tm time,
if (buffer[16] == 1 && errflags == 0)
dst_count++;
if (time.tm_min > 0)
dt_res.dst_announce = 2 * dst_count > time.tm_min;
dt_res.dst_announce = 2 * dst_count > minute_count;

if (buffer[17] != time.tm_isdst || buffer[18] == time.tm_isdst) {
/*
Expand Down Expand Up @@ -316,9 +316,11 @@ decode_time(unsigned init_min, int minlen, unsigned acc_minlen,
newtime.tm_isdst = time->tm_isdst; /* save DST value */

errflags = check_time_sanity(minlen, buffer) ? 0 : 1;

if (errflags == 0)
if (errflags == 0) {
handle_special_bits(buffer);
if (++minute_count == 60)
minute_count = 0;
}

increase = increase_old_time(init_min, minlen, acc_minlen, time);

Expand Down

0 comments on commit 25d5832

Please sign in to comment.