]> git.ipfire.org Git - thirdparty/shadow.git/commit
lib/strtoday.c: strtoday(): Fix calculation
authorAlejandro Colomar <alx@kernel.org>
Thu, 8 Feb 2024 11:53:24 +0000 (12:53 +0100)
committerAlejandro Colomar <alx@kernel.org>
Wed, 14 Feb 2024 03:10:03 +0000 (04:10 +0100)
commitc4eae35466f1e0d5594e94ad6fdb6c50695b385f
treeb8b365d7e7e745b3ed676600c8ca1f6333464e6c
parentd6a9b726037520be96dc5dcf88f0b9d165c3ccb3
lib/strtoday.c: strtoday(): Fix calculation

Days officially roll over at 00:00 UTC, not at 12:00 UTC.  I see no
reason to add that half day.

Also, remove the comment.  It's likely to get stale.

So, get_date() gets the number of seconds since the Epoch.  I wonder how
that thing works, but I'll assume it's something similar to getdate(3)
+ mktime(3).  After that, we need to convert seconds since Epoch to days
since Epoch.  That should be a simple division, AFAICS, since Epoch is
"1970‐01‐01 00:00:00 +0000 (UTC)".  See mktime(3).

Fixes: 45c6603cc86c ("[svn-upgrade] Integrating new upstream version, shadow (19990709)")
Link: <https://github.com/shadow-maint/shadow/issues/939>
Reported-by: Michael Vetter <jubalh@iodoru.org>
Tested-by: Gus Kenion <https://github.com/kenion>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Cherry-picked-from: 1175932c0c86 ("lib/strtoday.c: strtoday(): Fix calculation")
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Link: <https://github.com/shadow-maint/shadow/pull/942>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/strtoday.c