Summary
GNU date floors negative fractional epoch inputs (rounds toward negative infinity): @-1.5 → -2. parse_datetime truncates toward zero: @-1.5 → -1. The same off-by-one shows up on any negative fractional @N input.
Found by a fuzz_date run on uutils/coreutils.
Reproduction
$ LC_ALL=C TZ=UTC /usr/bin/date -d '@-1.5''+%s'-2
$ LC_ALL=C TZ=UTC target/debug/coreutils date -d '@-1.5''+%s'-1
$ LC_ALL=C TZ=UTC /usr/bin/date -d '@-893375784.554767216''+%s'-893375785
$ LC_ALL=C TZ=UTC target/debug/coreutils date -d '@-893375784.554767216''+%s'-893375784
Positive fractional epochs agree between the two.
Test (in uutils/coreutils integration suite)
#[test]fntest_date_negative_fractional_epoch_flooring(){new_ucmd!().env("LC_ALL","C").env("TZ","UTC").arg("-d").arg("@-1.5").arg("+%s").succeeds().stdout_is("-2\n");}
Summary
GNU
datefloors negative fractional epoch inputs (rounds toward negative infinity):@-1.5→-2.parse_datetimetruncates toward zero:@-1.5→-1. The same off-by-one shows up on any negative fractional@Ninput.Found by a
fuzz_daterun onuutils/coreutils.Reproduction
Positive fractional epochs agree between the two.
Test (in
uutils/coreutilsintegration suite)