sqlload 0.89.2

SQL data loading tooling.
1
2
3
4
5
6
7
8
9
/// `step` as a whole number of the largest of days, hours or minutes that divides it.
pub(crate) fn whole_units(step: std::time::Duration) -> Option<(u64, &'static str)> {
    let seconds = step.as_secs();
    let units = [(86_400, "day"), (3_600, "hour"), (60, "minute")];
    units
        .iter()
        .find(|(size, _)| seconds.is_multiple_of(*size) && seconds >= *size)
        .map(|(size, unit)| (seconds / size, *unit))
}