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

please consider adding additional format specifiers to jiff::fmt::strtime for strptime, strftime #139

Open
fdncred opened this issue Oct 2, 2024 · 3 comments

Comments

@fdncred
Copy link

fdncred commented Oct 2, 2024

The notable missing format specifiers from chrono, that I use pretty frequently, are:

spec example description
%c Sun Jul 8 00:34:60 2001 Locale’s date and time (e.g., Thu Mar 3 23:05:25 2005).
%+ 2001-07-08T00:34:60.026490+09:30 ISO 8601 / RFC 3339 date & time format. 

They're really just convenience formatters, but they're pretty convenient. 😄

@BurntSushi
Copy link
Owner

%c is probably a no-go if its specification is "the default format for the current locale." Jiff is very intentionally locale-unaware. I'm not sure if Chrono is even doing the right thing there. It would be better to use icu for that.

I am unsure about %+ because I'm not sure I want to encourage that format over RFC 9557 more than it already is. Moreover, it's unclear to me why you would use that when a Timestamp's default Display impl is exactly that: RFC 3339.

@fdncred
Copy link
Author

fdncred commented Oct 2, 2024

Moreover, it's unclear to me why...

Because I'm writing a nushell command to format dates where dt format <specifier> allows user to print the datetime in the format they specify and, it's more convenient to have specifiers that print the datetime with 2 characters rather than 10, or however many it would take. I can, of course, hard code custom specifiers and parse them in my code if you're not willing to add these.

@BurntSushi
Copy link
Owner

I'll noodle on that, but I think there may be an impedance mismatch here. The needs of a strtime DSL at the library level are likely somewhat different than the needs at a user facing CLI level. I'm still unsure of this because I want to be very careful about encouraging more offset-only formatting.

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