NervesTime.FileTime (nerves_time v0.4.9)

View Source

FileTime simulates a real-time clock using a file's mtime

The way it works is that a file is touched each time nerves_time wants to update the RTC. When nerves_time shuts down, the file is again touched. The next boot then reads the last modified time of the file so that nerves_time can set the clock to that value. It will certainly be off, but not absurdly so unless the device has been powered off for a really long time.

While this doesn't sound ideal at all, knowing the time within minutes, hours, or days can get the clock to within time ranges needed for X.509 certificate validation.

Summary

Functions

Return the timestamp of when update was last called or the Unix epoch time (1970-01-01) should that not work.

Update the file holding a stamp of the current time.

Update the timestamp one final time

Return the path to the file that keeps track of the time

Functions

get_time(path)

Return the timestamp of when update was last called or the Unix epoch time (1970-01-01) should that not work.

set_time(path, naive_date_time)

Update the file holding a stamp of the current time.

terminate(path)

Update the timestamp one final time

time_file()

@spec time_file() :: Path.t()

Return the path to the file that keeps track of the time