dotago

Crates.iodotago
lib.rsdotago
version0.1.0
sourcesrc
created_at2023-03-15 19:31:05.453799
updated_at2023-03-15 19:31:05.453799
descriptionsyntactic sugar for time calculations
homepagehttps://github.com/orhanbalci
repositoryhttps://github.com/orhanbalci/dotago.git
max_upload_size
id810930
size7,628
Orhan Balci (orhanbalci)

documentation

README

dotago

Crates.io Documentation License

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
Commit count: 8

cargo fmt