jiff/examples/uptime
Andrew Gallant 0541c1979c cargo: restore sanity to iterative development
I'm not sure when or how exactly it happened, but in the last weeks,
I've noticed that `rustc` gets effectively stun-locked whenever I make a
change to a source file in Jiff. A quick examination of what the fuck my
computer is doing seems to reveal that it's spending oodles of time
compiling diesel over and over.

I have no idea why this is happening and I don't really care to spend
the time unraveling the mysteries of diesel.

So I took a hammer to the problem. I have effectively shunted all
examples and all "integration" crates out of Jiff's core workspace and
into their own little bloated fiefdoms. To compensate for the fact that
`cargo test --all` no longer tests these things, I've added shell
scripts to run the requisite tests. And those shell scripts are now run
in CI.

I'm now back to a state where I can save a file in Jiff and I get
sub-second `cargo check` response times.
2025-04-10 20:54:30 -04:00
..
Cargo.toml cargo: restore sanity to iterative development 2025-04-10 20:54:30 -04:00
main.rs first substantial commit 2024-07-21 20:15:13 -04:00
README.md first substantial commit 2024-07-21 20:15:13 -04:00

This example shows how to parse the output of uptime on Unix and determine when the system booted. This demonstrates regex parsing, fallible construction of spans, zone aware arithmetic and rounding.

To run this program, use:

$ uptime | cargo run -qp uptime
2024-06-28T08:08:00-04:00[America/New_York]

If you don't have uptime, then you can pipe in data that looks like it came from uptime:

$ echo '14:00:47 up 12 days,  5:53' | cargo run -qp uptime
2024-06-28T08:08:00-04:00[America/New_York]