]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[libc] Allow out-of-range months in mktime() master 1764/head
authorMichael Brown <mcb30@ipxe.org>
Thu, 30 Jul 2026 09:27:01 +0000 (10:27 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 30 Jul 2026 09:27:01 +0000 (10:27 +0100)
commitfa779b1bce2331d286bfc8f70276fdad72ae9fa5
tree4e9a61e89174908e093de810e870d8d449a5d697
parent08c989f364576d3f0df3277cbb871bc3a62aad51
[libc] Allow out-of-range months in mktime()

POSIX specifies that the values of members of the broken-down time
structure are "not restricted to the ranges", and defines the way in
which out-of-range values are to be handled.

For most fields, the arithmetic is already purely linear and so
out-of-range values are handled automatically.  Out-of-range months
are an exception: these are used as array indices and so must be
normalised before use.

Restructure mktime() to make it more immediately visible when values
are being read from and written back to the broken-down time
structure, add the required normalisation for the month number, and
add test cases to cover out-of-range months.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/time.c
src/tests/time_test.c