-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
Support for strftime
formatters in 0.3
#341
Comments
Would a tool like the one for 0.1 to 0.2 alleviate concerns over transitioning? I don't dispute that it's more verbose, that's almost the point. I personally prefer to have something that can be both easily read and written, not just written (sorta like regex). Given the intermediate representation, I suppose it would be possible to have a parser for the older format. I'm not a huge fan of having two completely different formats, though, so that should probably fall to a third-party crate. With regard to documentation, you're the one that asked for a release without waiting for full docs 😛 The short format is "Jan" — all it does is truncate it to three letters, still following standard English capitalization. |
I've just updated the aforementioned tool to support converting 0.2 to 0.3. The only compatibility note here is that The format you included becomes
Note that the output of the tool does not include any modifiers that are default — in this case the year's repr defaults to the calendar year. |
The documentation here is incredibly hand-wavy:
Parsing needs to be very well specified. This is a blocker to migrating |
This is key. use time::macros::format_description;
use time::Date;
fn main() {
let date = Date::parse(
"19-002",
&format_description!("[year padding:none]-[ordinal]"),
)
.unwrap();
dbg!(date);
} The Formatting and parsing will be better documented. Were it not for your request, I likely wouldn't have even released 0.3 yet, as I wanted to have better documentation first. |
This is pretty weird and really unexpected. In any case, the converter should take this into account, then. I don't think
With respect to formatting, you've deviated substantially from the universally accepted, battle tested, understood norm. Yes, I totally missed this in pushing for the release, and I would have advocated for keeping the previous formatting spec, but even so I don't think this is a mater of "better" documentation but about precision. There's enough documentation to be useful, but not enough to know if my code is correct. This is also the piece of |
After quickly looking, this was likely a bug in 0.2. This function did not take the length of the consumed padding into account the same way it was here. Had I noticed it early on I probably would have fixed it. At this point it would effectively be a breaking change for 0.2. The converter could take this into account, but then the formatting wouldn't be the same, only parsing would.
Unquestionably. I still believe this was the best decision, as it allows for far more flexibility, expansion possibilities, and future performance improvement. Single-letter components was error prone when writing, nearly impossible to read, and had near-zero possibility for expansions like case insensitive parsing — something relatively easy to implement now.
It's hard to say definitively of course, but I likely would have improved documentation in that area, as I know it's still not thorough enough (I just wanted something basic to at least have it documented). |
Coming back around to this. I do not see this as something I want to support. All components and modifiers are currently public under the |
Shameless plug: I ended up with creating a crate doing it. It isn't "production-ready" quality (because I don't need that quality for my use case) and probably should be considered as a never-ending beta/experimental state, but in case anyone interested: https://github.com/MiSawa/time-fmt/ |
I'm really surprised to see that
strftime
formatting options are not available intime
. While the new formatting format is more readable, it's also significantly more verbose, and rewriting existingstrftime
formatting strings in this new format is error prone:The documentation is also lacking, so I have no idea if these are actually equivalent. Examples would help, especially if they are exhaustive. For example,
month
says:For the short format, is it written "Jan" or "jan" or "JAN"?
The text was updated successfully, but these errors were encountered: