OSDN Git Service

Teach date @unixtime[.fraction], switch -s to be -D (matching busybox and
authorRob Landley <rob@landley.net>
Sat, 8 Aug 2015 21:06:24 +0000 (16:06 -0500)
committerRob Landley <rob@landley.net>
Sat, 8 Aug 2015 21:06:24 +0000 (16:06 -0500)
commit5fb2766a9b51ee326a14ec9909066b20a2bfa9ac
treecde439ad83b28f92ba9976c189b9eb20ea5a0bbb
parent400dacdeb69bc13868a625fc2ce8b49b6acd5ae3
Teach date @unixtime[.fraction], switch -s to be -D (matching busybox and
not stomping on gnu's "an extra argument tells it to set the time so let's
add -s to do the same thing" extension).

Nanoseconds aren't uniformly supported by these apis, so had to stick it in
GLOBALS() and pull it out later. Awkward, open to suggestions for a better way.
(Also, the setting API is microseconds, not nanoseconds. Collect nano, convert
to micro so we can switch APIs later without changing date's external UI again.)

Oh, and shrink really_long_name_mktime() with a for() loop (and rename it)
although I may go back and redo that for portability to hypothetical libraries
if I can convert this mess to struct timespec with proper nanoseconds support.
But that needs an extended strptime() which needs an extended struct tm,
and between us and that is convincing posix computers got fast enough to
care about fractions of a second.

(Yes, I'm aware gnu added %N to date without adding it to strptime, implying
they reimplemented strptime longhand inside date. I'm not doing that.)
toys/posix/date.c