-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
date: date.pl gnu test tracker #10242
Description
Yesterday investigated all of the remaining failures in the main date.pl test to identify the root causes and see what it would take to fix the issues. Was able to come up with a prototype of changes that make all of the tests pass but came across some instances where the issues are upstream in the jiff library. Around half of those issues appear to be bugs, but the other half appear to be deliberate decisions.
Was hoping to start the discussions early on what those incompatibilities are to see if there's a possibility we could work with @BurntSushi to see if there is some sort of way that we can add specific features to Jiff under some sort of gating or flag.
To start off with the issues that can be resolved by directly changing the uutils code from:
5, dbg_5, 8, dbg_8, tz-5wf
These two tests are failing first because the default strtime::format uses %-I instead of %I which causes hours like 8 to be formatted as 8 instead of 08. This can be fixed by using a Jiff config to do the format and running it with PosixCustom::new() which uses the posix compliant default formats. The second issue here is that Jiff has taken the stance that when inproperly formatted formats are provided, instead of treating it as a literal it will return an error. Jiff has added the .lenient(true) flag to maintain compatibility so we just need to add that to the custom config.
// TODO: Switch to lenient formatting.
Ok(date) => match strtime::format(format_string, &date) {
let config = Config::new().custom(PosixCustom::new()).lenient(true)
match BrokenDownTime::from(&date).to_string_with_config(&config, format_string) {
relative-2
This is another one that can be addressed in uutils. Essentially we need read the -utc flag and modify the now that is passed to the formatter and set the timezone to UTC when this flag is set.
rel-2b, leap-1
The next issue is a bug in the parse_datetime library, which is not a big deal because its a uutils library. The high level gist is that the current behavior of the DateTimeBuilder where it was doing:
let days = dt.date().last_of_month().day() as i32;
Span::new().try_days(days.checked_mul(x))?
This converted months to days using the current month's length, which loses days when months have different lengths. This can just be fixed by changing the logic to not use the built in jiff function and make one that doesn't clamp based on the current month but actually determines the correct month. I did not find a different helper function that does that to swap to so we will probably have to add this new helper function in parse_datetime.
invalid-high-bit-set
This one is just non utf-8 handling, we just need to change the input to OsString, but this can be handled in the uutils implementation.
neg-secs, neg-secs2
These ones I think are actual bugs in the Jiff library that are not intended behaviors. When adding padding, the negative sign goes ontop of the padding and will produce outputs like - 22, instead of -22
Upstream Non-Bugs
subfmt-up1, date-century-plus
These two tests correspond to the modifiers %^c and %+. In the Jiff docs the %+ is explicitly stated as something that is not supported in Jiff because "* The %+ conversion specifier is not supported since there doesn't seem to be any consistent definition for it." Then there is also the ^ for c where in general the ^ modifier is supported, which is unclear whether that is a deliberate choice or whether it is something that is just incomplete.
What I was hoping to propose is that if @BurntSushi would be okay with it, is if we could do something similar to the lenient flag or a feature flag for GNU compatibility, to add the %+ conversion only as an opt in with the conditions that the + is following the GNU spec for it.