osmio 0.14.0

Read and write OpenStreetMap data files
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Misc local utilities
use chrono::{offset::Utc, DateTime};

pub fn epoch_to_iso(epoch: i32) -> String {
    // Chrono is a little silly and can't easily convert from epoch to utc timezone
    let d: DateTime<Utc> =
        DateTime::from_timestamp(epoch as i64, 0).expect("epoch timestamp too high");
    d.to_rfc3339_opts(chrono::SecondsFormat::Secs, true)
}

pub fn iso_to_epoch(iso: &str) -> u32 {
    DateTime::parse_from_rfc3339(iso)
        .map(|x| x.timestamp() as u32)
        .unwrap_or(0)
}