Skip to content

date: print unknown %f and %Q conversions literally like GNU - #14672

Open
Dummy-pixel-hash wants to merge 3 commits into
uutils:mainfrom
Dummy-pixel-hash:date-literal-percent-f
Open

Dummy-pixel-hash wants to merge 3 commits into
uutils:mainfrom
Dummy-pixel-hash:date-literal-percent-f

Conversation

@Dummy-pixel-hash

Copy link
Copy Markdown
Contributor

Fixes #14600.

jiff implements %f (fractional seconds) and %Q (timezone abbreviation), which GNU leaves literal, so date +%f printed nanoseconds. This escapes those specifiers, with any flags or width, into literals before formatting, matching GNU output including its width and flag quirks for unknown conversions. It also keeps %O on %Of/%OQ, where it cannot be a modifier.

jiff implements %f (fractional seconds) and %Q (timezone abbreviation),
which GNU leaves literal, so `date +%f` printed nanoseconds. Escape those
specifiers, with any flags or width, into literals before formatting,
matching GNU output including its width and flag quirks for unknown
conversions. Also keep %O on %Of/%OQ, where it cannot be a modifier.

Fixes uutils#14600.
@codspeed

codspeed Bot commented Sep 18, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 22.06%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 9 untouched benchmarks
⏩ 408 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation complex_relative_date 396.4 µs 324.8 µs +22.06%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Dummy-pixel-hash:date-literal-percent-f (a5a6640) with main (b60091b)2

Open in CodSpeed

Footnotes

  1. 408 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (41c3451) during the generation of this report, so b60091b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/misc/tty-eof (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/unexpand/bounded-memory is now passing!

Some(format_with_modifiers(date, format_string, config))
}

/// Escape conversion specifiers that jiff renders but GNU `date` leaves literal.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need 20 lines of comments that nobody will read? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gnucompatibility(date): +%f treated differently, gnu vs uu

2 participants