graphile_worker_crontab_runner 0.7.7

Crontab runner package for graphile worker, a high performance Rust/PostgreSQL job queue
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use chrono::{prelude::*, Duration};
use once_cell::sync::Lazy;

pub(crate) static ONE_MINUTE: Lazy<Duration> = Lazy::new(|| Duration::minutes(1));

pub(crate) fn round_date_minute<Tz: TimeZone>(
    mut datetime: DateTime<Tz>,
    round_up: bool,
) -> DateTime<Tz> {
    datetime = datetime.with_second(0).unwrap().with_nanosecond(0).unwrap();
    if round_up {
        datetime += Duration::minutes(1);
    }
    datetime
}