1 unstable release
0.1.0 | Mar 15, 2023 |
---|
#398 in Date and time
Used in crabst
8KB
139 lines
dotago
This crate is a rustlang port of dotago.js npm package written by @alexpusch.
📦 Cargo.toml
[dependencies]
dotago = "0.1"
🔧 Example
Work with dates
use dotago::Dotago;
// now: 2023-03-15T10:00:00Z
1.minute().ago().as_date(); // 2023-03-15T09:59:00Z
2.hours().ago().as_date(); // 2023-03-15T08:00:00Z
3.hours().from_now().as_date(); // 2023-03-15T13:00:00Z
Work with timestamps
use dotago::Dotago;
// now: 2020-06-18T10:00:00Z
1.minute().ago(); // 1592474340000
1.hour().ago(); // 1592470800000
1.hour().from_now(); // 1592478000000
Duration in milliseconds
use dotago::Dotago;
1.second(); // 1000
1.minute(); // 6000
1.hour(); // 3600000
Do math
use dotago::Dotago;
// now: 2020-06-18T10:00:00Z
(1.hour().ago() + 2.minutes()).as_date(); // 2020-06-18T09:02:00Z
Dependencies
~1MB
~18K SLoC