Skip to content

Estimate "real" time when offline and system clock cannot be trusted

License

Notifications You must be signed in to change notification settings

cktang88/truetime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

truetime

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.

Usage

# install deps
pip3 install uptime ntplib
# run script
python3 ./main.py

Assumptions

  • Assumes system interacts w/ temp directory files on a roughly continuous and consistent basis.

How it works

Uses an NTP server when online.

When offline, estimates time from system temp directory files.

Steps:

  1. 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
  2. calculate how much time has elapsed since that time
    • TBD
  3. add the offset to the earlier timestamp

About

Estimate "real" time when offline and system clock cannot be trusted

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages