kumo_chrono_helper/
lib.rs1pub use chrono;
2pub use chrono::{DateTime, TimeZone, Utc};
3
4#[allow(deprecated)]
14pub const MINUTE: chrono::Duration = chrono::Duration::minutes(1);
15
16#[allow(deprecated)]
17pub const SECOND: chrono::Duration = chrono::Duration::seconds(1);
18
19#[allow(deprecated)]
20pub const HOUR: chrono::Duration = chrono::Duration::hours(1);
21
22pub fn seconds(seconds: i64) -> anyhow::Result<chrono::Duration> {
23 chrono::Duration::try_seconds(seconds).ok_or_else(|| {
24 anyhow::anyhow!("{seconds} is out of range for chrono::Duration::try_seconds")
25 })
26}
27
28pub fn minutes(minutes: i64) -> anyhow::Result<chrono::Duration> {
29 chrono::Duration::try_minutes(minutes).ok_or_else(|| {
30 anyhow::anyhow!("{minutes} is out of range for chrono::Duration::try_minutes")
31 })
32}
33
34pub fn days(days: i64) -> anyhow::Result<chrono::Duration> {
35 chrono::Duration::try_days(days)
36 .ok_or_else(|| anyhow::anyhow!("{days} is out of range for chrono::Duration::try_days"))
37}