Cross-platform estimate of "true" time in very adverse conditions:
- offline
- unreliable/untrusted system local time (eg. user keeps changing the time forwards and/or backwards in time).
- user may also shut down/put to sleep/hibernate system for abnormal periods of time.
- this script is NOT running in the background, and only allowed to run occasionally.
Warning: this is experimental, use at your own risk.
# install deps
pip3 install uptime ntplib
# run script
python3 ./main.py
- Assumes system interacts w/ temp directory files on a roughly continuous and consistent basis.
Uses an NTP server when online.
When offline, estimates time from system temp directory files.
Steps:
- get earliest timestamp that appears trustable
- scan all files in temp dir, storing timestamps for file creation, file modification, and file last accessed
- calculate gaps between those timestamps
- earliest trustable timestamp is the time before earliest gap
- calculate how much time has elapsed since that time
- TBD
- add the offset to the earlier timestamp