I’ve done some more thinking. It looks a bit contradictory to have
%Nfmeans “take the integer%f(microsecond number) and truncate to the highestNof 6 digits”%Nmmeans “take the integer%m(month number) and pad toNdigits”
but also %.Nf instead of %Nf is weird, arguably worse, because
.is not used in anystrftime(3)specifiers (I was confused with *printf(3)*, my bad
).- Even if taking inspiration from
printf(3)for this thread, microseconds is not a float (whichprintf(3)'s and Python’s precision.truncates toNdigits) but rather it is an integer, whichprintf(3)'s (and Python’s upcoming PEP 786’s).pads to a minimum number of digits, whereas we want to format to a fixed number of digits (6 for microseconds) and then truncated to the highestN.
Either syntax %Nf or %.Nf is going to be exceptional because of the niche task of formatting an integer to 6 digits, then truncating to the highest N.
However, %f is not part of strftime(3). It’s explicitly a Python extension. So either syntax we choose we don’t have to worry about it ‘breaking’ strftime(3). I think it reduces to just a question of “which syntax looks nicer / is most intuitive?”.
I think I prefer the %Nf syntax based off the understandable questions of
etc, firstly from a visual analysis to stop confusion
> “there’s a . in the specifier, where is the . in the output?”
and secondly as @jsbueno points out Rust’s strftime has different behavior for %.3f and %3f, and we want the behavior of the latter.
TLDR: I retract my %.Nf inquiry and I’m +1 on %Nf.