Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document '%f' microsecond formatter (appears to come from Python, not glibc?) #3

Closed
mroth opened this issue May 7, 2022 · 1 comment

Comments

@mroth
Copy link

mroth commented May 7, 2022

I see a %f microsecond modifier was added in 720f6bf.

I would like to suggest possibly documenting this in the readme and Go documentation.

The readme currently mentions the glibc extensions, and both the readme and g docs link to https://linux.die.net/man/3/strftime for full formatter documentation. As far as I can tell though, it appears %f is not included in those glibc strftime extensions?

From what I can tell via web searches, it may come from the python datetime library, which in its documentation points at the C89 reference ("The following is a list of all the format codes that the 1989 C standard requires, and these work on all platforms with a standard C implementation"). However, the %f format specifier does not appear to actually appear in the C standard, even after the C99 extensions: https://en.cppreference.com/w/c/chrono/strftime. I can't find a reference to it in any other strftime implementation outside of Python, so I guess that may be where it originated?

Either way, it's useful, but I only found it via the source code, so I'd recommend documenting it for posterity. (I can make a PR if you prefer, but not sure how you would like to explain it in the docs.)

@itchyny
Copy link
Owner

itchyny commented May 8, 2022

Thanks for reporting. The original intention was to support microseconds in gojq, after seeing jqlang/jq#1409. Also I looked imperfectgo/go-strftime which supports this directive, but I failed investigate its origin. Though this library was intended not to include an extension like this, but %f is already used by the dependants, so hardly to drop support. I'll add a note in README.md.

@itchyny itchyny closed this as completed in 8fc1aed May 8, 2022
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

No branches or pull requests

2 participants