cursive
cursive copied to clipboard
`chrono` is using a very old version of time, any chance of switching to modern `time`?
Currently cursive is bringing in chrono
, which hasn't been updated in over 8 months and it's using a very very old version of the time
library where the modern time
library versions are significantly more functional and overall more useful, with a lower dependency count, especially as cursive isn't using any features that are chrono-only that I can see (I'm not sure there are any anymore compared to modern time's now?), any chance of switching to modern time
itself instead as its more actively maintained (and about to have a 0.3.0 update)?
Hi, and thanks for the report!
I'm having a look at replacing chrono with time, and so far I see a few issues.
- I did not find an easy way to format the time with only a few digits for the fractional seconds. Ideally I'd like ~2-3 digits; chrono had
%.3f
but I did not see anything apart from%N
intime
, which includes all 9 digits. I suppose it would be possible to format all 9 digits it to a string that we'd truncate? Not super clean, but that may work. -
time
0.3 seems to remove thelazy_format
method, replacing it withformat_into
which is not quite as ergonomic to use.
In our case, chrono is only used for the DebugView, where we already use format!
to create a string, so we should be able to use format_into
on this string, and truncate the extraneous digits.
~~
EDIT: Ok looking at the current pre-release version of time, I found how to use 2 fractional digits. https://github.com/time-rs/time/issues/328 still means that I need to either:
- Allocate a new string on each date formatting, thus paying a (small) performance cost
- Write the formatted date to a re-usable
Vec<u8>
and parse it as a string, paying a (small) performance cost validating utf8.- Same as above but using
unsafe
since we know the output is going to be validutf8
.
- Same as above but using
It's not terrible - I could live with either of these 3 solutions. But then I realized the default behavior on linux/macOS is to not use the local timezone (https://github.com/time-rs/time/issues/293). The "workaround" is a custom RUSTFLAGS, something only the end-user can do, so every user of cursive would have to do that in order to have correct times. That's not really a great situation.
It seems to be part of a larger freaking out about getenv
/setenv
not being sound. It's probably somewhat justified, but the end result is a rather fundamental piece of logic (retrieving and printing the current time) that's broken by default for most users.
So I may wait until the situation settles a bit before changing something here.