Skip to content

Commit a3b8730

Browse files
committed
waveform: Fix transmitted time for DCF77/MSF
Fix logic for computing transmitted time immediately prior to summer time switchovers (CEST/CET or UTC/BST).
1 parent 4301f4f commit a3b8730

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/wasm/waveform.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,15 @@ static void tsig_xmit_dcf77(tsig_datetime_t datetime, tsig_params_t *params,
221221
double utc_timestamp = datetime.timestamp - utc_offset;
222222
tsig_datetime_t utc_datetime = tsig_datetime_parse_timestamp(utc_timestamp);
223223

224+
/* Transmitted time is the CET/CEST time at the next UTC minute. */
224225
uint32_t in_mins;
225226
uint8_t is_cest = tsig_datetime_is_eu_dst(utc_datetime, &in_mins);
227+
uint8_t is_xmit_cest = is_cest ^ (in_mins == 1);
228+
226229
bits[16] = in_mins <= 60;
227-
bits[17] = is_cest;
228-
bits[18] = !is_cest;
230+
bits[17] = is_xmit_cest;
231+
bits[18] = !is_xmit_cest;
229232

230-
/* Transmitted time is the CET/CEST time at the next UTC minute. */
231-
uint8_t is_xmit_cest = (is_cest && in_mins > 1) || (!is_cest && in_mins == 1);
232233
uint32_t cest_offset = is_xmit_cest * TSIG_DATETIME_MSECS_HOUR;
233234
uint32_t xmit_offset = TSIG_DATETIME_MSECS_MIN;
234235
double xmit_timestamp = datetime.timestamp + cest_offset + xmit_offset;
@@ -457,7 +458,7 @@ static void tsig_xmit_msf(tsig_datetime_t datetime, tsig_params_t *params,
457458
uint8_t is_bst = tsig_datetime_is_eu_dst(datetime, &in_mins);
458459

459460
/* Transmitted time is the UTC/BST time at the next UTC minute. */
460-
uint8_t is_xmit_bst = (is_bst && in_mins > 1) || (!is_bst && in_mins == 1);
461+
uint8_t is_xmit_bst = is_bst ^ (in_mins == 1);
461462
uint32_t bst_offset = is_xmit_bst * TSIG_DATETIME_MSECS_HOUR;
462463
uint32_t xmit_offset = TSIG_DATETIME_MSECS_MIN;
463464
double xmit_timestamp = datetime.timestamp + bst_offset + xmit_offset;

0 commit comments

Comments
 (0)