osmanthus 1.0.0

Find and automatically format time text from the string
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use osmanthus::parse_relative;
use osmanthus::bind::Param;

fn main() {
    let samples = vec![
        "发布于 - /n6小時前,",  // 6 hours ago
        "( 시간: 3분 전)", // 3 minute ago
        "- about / 2 minutes ago", // 2 minutes ago
        "30天前 来源:新华网", // 30 days ago
        "publish 5 second ago." // 5 second ago.
    ];
    for sample in samples{
        let r =parse_relative(sample, Some(Param{strict: true, ..Default::default()}));
        let datetime = r.datetime.local.datetime;
        println!("relative time text parse result: {:?}, status: {}", datetime.format("%Y-%m-%d %H:%M:%S").to_string(), r.status);
    }
}