[libc/cmds] Fix time command hour wrapping problem by ghaerr · Pull Request #1722 · ghaerr/elks (original) (raw)
Fixes time command sometimes displaying incorrect results, reported by @Vutshi in #1619 (comment).
time would report incorrect results (e.g. an extremely large number) when a command would execute for a period of time where the number of seconds since Jan , 1970 would "wrap" during a modulo 3600 operation. Long story short, previously time used microsecond time calculations with a 32-bit long which was subjected to the improper 3600 second modulo operation approximately every hour GMT. It has been rewritten to use 64-bit arithmetic and is no longer subject to any time modulus.
The times C library routine has been removed due to being incorrect, and an alternative method used to get times in time.
@Vutshi, time sl -s should display properly now, although I don't expect you to actually wait 34 minutes to test it!