Skip to content

ntptime wrong NTP_DELTA #786

@DracoTomes

Description

@DracoTomes

Hi,

the NTP_DELTA values for the different epochs seem the wrong way around.

The following happens on my ESP32:

import ntptime, utime

print(utime.gmtime(0)[0])
print(ntptime.time())
2000
757785416

This timestamp is sometime in 1994.

If I switch the deltas around I get the correct timestamp from ntptime.

2000
1704471142
if EPOCH_YEAR == 2000:
    # (date(2000, 1, 1) - date(1900, 1, 1)).days * 24*60*60
    #old NTP_DELTA = 3155673600
    NTP_DELTA = 2208988800
elif EPOCH_YEAR == 1970:
    # (date(1970, 1, 1) - date(1900, 1, 1)).days * 24*60*60
    #old NTP_DELTA = 2208988800
    NTP_DELTA = 3155673600

But this doesn't make sense intuitively... Somehow 1970-1900 needs to be bigger than 2000-1900.

Maybe something about the port is off? I'm running

MicroPython infos: (sysname='esp32', nodename='esp32', release='1.22.0', version='v1.22.0 on 2023-12-27', machine='Generic ESP32 module with ESP32')

on a ESP-32-Wroom-32 from AZ-Delivery.

Any tips are appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions