Skip to content

Commit 8a77b2f

Browse files
bradkeifermarcelveldt
authored andcommitted
ntp epoch is 1900, not 1970
1 parent f1b89e4 commit 8a77b2f

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/raop_client.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ uint64_t raopcl_get_ntp(struct ntp_s* ntp)
216216
{
217217
uint64_t time = gettime_us();
218218
uint32_t seconds = time / (1000 * 1000);
219+
seconds += NTP_EPOCH_DELTA; // Convert to NTP epoch (1900-01-01)
219220
uint32_t fraction = ((time % (1000 * 1000)) << 32) / (1000 * 1000);
220221

221222
if (ntp) {

src/raop_client.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ typedef struct ntp_s {
7272
uint32_t fraction;
7373
} ntp_t;
7474

75+
#define NTP_EPOCH_DELTA 0x83aa7e80 /* 2208988800 - that's 1970 - 1900 in seconds */
7576
#define NTP2MS(ntp) ((((ntp) >> 10) * 1000L) >> 22)
7677
#define MS2NTP(ms) (((((uint64_t) (ms)) << 22) / 1000) << 10)
7778
#define TIME_MS2NTP(time) raopcl_time32_to_ntp(time)

0 commit comments

Comments
 (0)