-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
Time v0.3 tracking issue #248
Comments
As a result of packing the
A simple benchmark (not published) also shows a ~30% improvement in performance! |
As a suggestion, I think it would be useful to have a release candidate for 0.3, when you feel it's ready, to work out any remaining issues in dependent crates. There are a few API nags in 0.2 that I'd love to see resolved in 0.3. |
@SergioBenitez Definitely planning on a release candidate. Main thing I want to get done is the revamped formatting, as that's a major change. Are there any APIs in particular you'd prefer changed that aren't addressed by the list above? |
An update on no-alloc support: Once revamped formatting/parsing is complete, I'll likely release an alpha for initial review. While I'm designing the formatting/parsing with no-alloc support in mind, support for dynamic formatting strings seems unlikely, at least at first. The ability to have modifiers for the various specifiers would be quite inefficient (quadratic versus linear for checking in alloc environments). However, this doesn't preclude the possibility of statically known formats, namely those in the I will investigate the possibility for no-alloc support for other operations. Given that error handling for constructors currently required I could use the arrayvec and/or heapless crates, but dependencies can't (currently) be disabled by enabling a feature flag (name alloc). |
@jhpratt I'm not sure what's changed in
|
|
I suppose I'm less concerned about the fact that it's a proc-macro and more concerned about the heavy-weight dependencies being pulled in. The macros are fairly straight-forward, so you should be able to accomplish the same thing without pulling in any dependencies whatsoever.
I suppose I'm confused about calling
I believe you're suggesting something like:
I've noted a few in my comment already. Each different date/time type needs to detail 1) why it exists, 2) how to create it, and 3) how it relates to the other types. There should also be a high-level overview of the library on common ways it's intended to be used. |
The original reason for pulling in the dependencies was proc-macro-hack. I can likely take a look at how that actually works and write the code myself (until the crate's MSRV allows for
Something like Also, turns out it was trivial to create a
Yes, that's the sort of thing I was referring to. One major reason to keep the types separate is that a With regard to renaming
👍 |
In case it helps, here is a minimal implementation of |
Thanks @Plecra. I didn't realize it at the time, but proc macro hack actually no longer relies on syn and quote. So relying on that for a sufficient time period (such that my MSRV guarantees are upheld) is a non-issue. The time to compile it by itself is negligible enough that I'm fine keeping it. |
@jhpratt It seems that time-macros does indirectly depend on |
@yorickpeterse It's already been removed on the v0.3 branch. |
@jhpratt Ah thanks! In that case I'll keep an eye on this issue. |
I don't know if that is the correct issue for this but it seems you're looking for feedback on the API, so I will just dump my thoughts here. The reason I am checking out this crate is that I want update an old crate of mine (I am talking about full face lift level update) and add the time crate as optional dependency to use its types or at least conversions. Overall I am not in a rush because there is so much work 😅 Naming Inconsistencies
API Inconsistencies
OffsetDateTime At first I wanted to suggest to rename it to
There in fact two types of date times that are still date times at the end of the day. Floating date times are ambigious or relative to the observer. If I said I always want to go jogging at 17 o' clock, it wouldn't matter whether I am in Germany or China. Though for server logs one would prefer to have them in UTC time or at least local time because servers are not necessarily in the same time zone as the developer or customer. Overall the current API for date times is fine but it lacks documentation. Misc I hope that this long comment is useful for development! |
This issue works!
I sure hope you're not in a rush, because I've still no solid timeline for time 0.3 😛 My best guess is late this year or early next.
With regard to
If we're changing the others, we may as well change this one to
As noted above.
👍
Technically what's being passed is actually the Julian day number. Admittedly, the difference between a JDN and Julian date is…confusing at best. A doc alias should certainly be added here.
Time for me to look over the API naming guidelines! From the table provided,
As with above,
I'll probably wind up changing
As with above,
This one I don't quite like.
Agreed. I can change this to
Macros! The macros provided guarantee a statically-known, const-compatible value. As all constructors have checks for the parameter validity, I needed some way to construct a
Note that this crate makes near-zero effort to be ISO 8601 compatible.
I'm not sure if you ran across this, but With regard to
Documentation definitely could use some work, no question there. Fractional seconds (which is what I presume you meant) are supported, though. The only struct that has a "seconds" component without a subsecond value is
It definitely is! Thanks for making it 🙂 |
The For the top level documentation short lists for features, goals, non-goals, roadmap etc. could help without writing too much. Otherwise, I think the corrections you made to my comment could be a good starting point for documentation. |
As a breaking release, I think the Edit: Also the re-export of |
@RagibHasin It's quite common for crates to have top-level exports named |
Oh, my bad. I actually glob imported everything from this crate. Selectively importing items would solve this. Thanks. |
Glob imports generally aren't a good idea either, aside from |
Also, now as I came across serializing, it does something totally unprecedented for me. I used My suggestion is to implement this for |
@Plecra I first saw that a few weeks ago. It's enabled behind the |
Today I was trying to use this crate just for getting formatted date time string as its not avail in stdlib. But unfortunately I don't see any examples, guides etc. I searched on duckduckgo but no luck. After 10-15 minutes i found the answer but it would be nice to have guide like https://rust-lang-nursery.github.io/rust-cookbook/datetime.html which is for chrono.
|
@shirshak55 As I noted just three days ago in this issues, I still have to work on documentation for 0.3. |
Using standard ISO 8601 for human readable output by default will simplify the use with web services / JSON. |
That's a good point, and I'll certainly consider making the change. As a bonus, I'm pretty sure it's faster, but I haven't done a direct comparison yet. |
Quickly looked into using RFC3339 for the human readable output of serde. This won't happen for a two reasons:
While most people will need neither of these, I'm not comfortable putting a restriction like that in place when it should be general purpose. ISO8601 allows for larger & smaller years if I remember correctly, but the standard is not freely available (so I can't even verify this without paying a significant amount of money). I don't recall if ISO8601 supports UTC offsets with second precision. |
I was thinking, what about create two features, |
Example: #[derive(Serialize)]
struct Hello {
// use the current default
timestamp1: OffsetDateTime,
#[serde(with = "time::formats::iso8601")]
timestamp2: OffsetDateTime,
} |
As I stated, it's not possible to use RFC3339 as a serde format for the general purpose. Changing defaults by toggling a feature flag would be dangerous, as this would mean that a library and end user could each enable one on their own (having both enabled would be a compile error). I'm not opposed to adding more well-known formats (that's why it's an entire module), but they should be able to perform a roundtrip without losing information. In theory I could have a well-known format that could only be serialized or deserialized, but I'm not sure why that would be the case. I split the trait into two already, so the technical means to do so already exists. Serde-specific formats would go under the |
Time 0.3.0-alpha.0 is out! The changelog is mostly accurate, though there's certainly some things to be updated. For documentation of the new format description, check out this page. I intend on filling out more of the book and updating some inline documentation before a final 0.3 release. |
Looks like all of the items have been checked off. How do you feel about a proper stable release? |
It's mostly documentation to be honest. I just started working on the book again yesterday, but I've got quite a bit else going on. I should figure out how to best present the format description info in the inline documentation. Other than that there's a couple places where I think documentation is inaccurate with recent changes. Once these happen it should be all set 🤞🏽 |
^^ a migration guide also needs to be made |
If the functionality is complete, I would encourage you to publish even without the book or migration guide. I suspect that the utility of these extra pieces of documentation are not of significant enough value, given the nature of the library, to warrant delaying the release. And, in my experience, these pieces tend to take an inordinate amount of time. |
That's reasonable. I'll take a bit of time tonight to ensure none of the existing documentation is outright wrong and check that the changelog is up-to-date. Neither of those should take too long. If it goes well I'll cut a release tomorrow. |
Pending the outcome of the full powerset on a number of targets (https://github.com/time-rs/time/actions/runs/1077701313), the current master branch will become v0.3.0. It normally takes a bit over an hour to run, so I'll get to it when I'm on my laptop next. |
Looks like the CI is green! One thing I noticed in giving this a go is that The obvious approach is to feature gate these, perhaps via an aptly named Edit: After taking a closer look, it seems that bringing the MSRV down to 1.48 without any dependencies would be rather straightforward except for perhaps a single function. For 1.48, we'd need:
That only leaves |
Given that I would like to state for the record that I will be tracking the six-month timeframe quite closely in the future though. I keep track of a number of unstable and recently stabilized features here along with the date on which I also just realized I goofed and didn't bump |
Welp, new release means new lints that I should probably fix before publishing! It'll be out tonight. |
It's exactly because ~/Local/time ❯ time cargo build
Compiling version_check v0.9.3
Compiling const_fn v0.4.8
Compiling easy-ext v0.2.9
Compiling standback v0.3.5
Compiling time v0.3.0 (/Local/time)
Finished dev [unoptimized + debuginfo] target(s) in 6.73s
cargo build 6.01s user 0.81s system 99% cpu 6.824 total
That's a 4.7x speedup! I cannot imagine justifying a 4.7x slowdown to decrease the MSRV by a single point release. |
If the
|
Huh, didn't realize the dependencies added that much to compile time. Given that information, I'll bump MSRV to 1.48. 1.49 is the highest we could go given policy, so it's still in line with that. |
Time 0.3.0 has been released. |
Time v0.2 was an outstanding learning experience, and by all accounts is a massive improvement over v0.1. However, a number of ill-informed decisions were made which led to some inconsistencies and many deprecated APIs.
All deprecated methods and structs have ready-to-use alternatives, which will be detailed before a release. As such, I would like to remove all deprecated APIs. This currently includes the following.
Deprecated APIs
PreciseTime
SteadyTime
precise_time_ns
precise_time_s
Instant::to
Duration::num_weeks
Duration::num_days
Duration::num_hours
Duration::num_minutes
Duration::num_seconds
Duration::num_milliseconds
Duration::num_microseconds
Duration::num_nanoseconds
Duration::span
Duration::from_std
Duration::to_std
Date::from_ymd
Date::from_yo
Date::from_iso_ywd
Date::with_hms
Date::with_hms_milli
Date::with_hms_micro
Date::with_hms_nano
Time::from_hms
Time::from_hms_milli
Time::from_hms_micro
Time::from_hms_nano
Date::today
Time::now
PrimitiveDateTime::now
PrimitiveDateTime::unix_epoch
PrimitiveDateTime::from_unix_timestamp
PrimitiveDateTime::timestamp
OffsetDateTime::now
Sign
Duration::sign
PrimitiveDateTime::using_offset
Goals for v0.3:
Remove all deprecated APIsRevamped parsing/formatting (Revamped parsing/formatting #236)un-constifyis_leap_year
anddays_in_year
for performance. On Rust ≥ 1.46,cfg_if_match
andcfg_loop
are stable, which allows re-enabling this without runtime performance loss. As a result, the only "loss" is un-constifying methods on older compilers.Place macros behind a feature flag.Change a number of methods to returnResult
, including allUtcOffset
constructors.Renametry_from_*
to justfrom_*
.#![no_alloc]
supportRenameOffsetDateTime::timestamp
andOffsetDateTime::timestamp_nanos
toOffsetDateTime::unix_timestamp
andOffsetDateTime::unix_timestamp_nanos
respectively.Stabilize serde representationsAnything stricken on the above list is completed. Anything that was previously on the list but was removed was either done in 0.2 (if it's not a breaking change) or abandoned.
The text was updated successfully, but these errors were encountered: