Here's a VS1010D utility program to set the current time of the RTC to whatever is the latest file creation or modification time in a given directory, if it's later than the current time of the RTC.
Usage: SetTimeFrom [?][!][folderspec]
Folderspec can be a drive such as S: or D: or a subdirectory such as S:SYS or D:MUSIC. If folderspec is omitted, then S: is used as the default. Question mark prints the current RTC time or the default time if RTC is clearly messed up. Exclamation mark forces the RTC value to be set.
When invoked, the program scans all file entries in a given directory and determines which file entry has the largest creation or modification timestamp. If that is beyond the current value of the hardware RTC counter, the value of the hardware RTC counter is updated.
For example:
Additionally, if your goal is to get correct timestamps to files written by the VSOS, you need to RunLib("RTCREAD",NULL); to update the system time from the RTC hardware before closing a file. This step can be automated by setting a handler for the GetTimeFromRtc system hook.VSOS Console wrote:VS1010>settimefrom !0:
No device 0.
Time of RTC is 2000-01-01 00:00:00
Updating RTC hardware register...
VS1010>settimefrom ?
Time of RTC is 2000-01-01 00:00:05
VS1010>settimefrom
Time of CONFIG.TXT is 2020-01-02 13:06:32
Updating RTC hardware register...
VS1010>settimefrom S:SYS
Time of SETTIM~1.DLX is 2020-01-02 16:57:20
Updating RTC hardware register...
VS1010>settimefrom S:
Time of RTC is 2020-01-02 16:57:30
VS1010>settimefrom !S:
Time of CONFIG.TXT is 2020-01-02 13:06:32
Updating RTC hardware register...
VS1010>settimefrom ?
Time of RTC is 2020-01-02 13:06:59
VS1010>settimefrom ?
Time of RTC is 2020-01-02 13:07:04
VS1010>
See also: RTC aware file copy.
-Panu