All Projects → bspeice → Dtparse

bspeice / Dtparse

Licence: other
A dateutil-compatible timestamp parser for Rust

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Dtparse

Redbpf
Rust library for building and running BPF/eBPF modules
Stars: ✭ 611 (+1257.78%)
Mutual labels:  rust-library
Rusticsom
Rust library for Self Organising Maps (SOM).
Stars: ✭ 18 (-60%)
Mutual labels:  rust-library
Arccstr
Thread-safe, reference-counted null-terminated immutable Rust strings.
Stars: ✭ 34 (-24.44%)
Mutual labels:  rust-library
Lopdf
A Rust library for PDF document manipulation.
Stars: ✭ 720 (+1500%)
Mutual labels:  rust-library
Superslice Rs
Extensions for ordered Rust slices.
Stars: ✭ 17 (-62.22%)
Mutual labels:  rust-library
Rust Csv
A CSV parser for Rust, with Serde support.
Stars: ✭ 911 (+1924.44%)
Mutual labels:  rust-library
Printpdf
An easy-to-use library for writing PDF in Rust
Stars: ✭ 404 (+797.78%)
Mutual labels:  rust-library
Log
Logging implementation for Rust
Stars: ✭ 1,012 (+2148.89%)
Mutual labels:  rust-library
Libimagequant Rust
libimagequant (pngquant) bindings for the Rust language
Stars: ✭ 17 (-62.22%)
Mutual labels:  rust-library
Photon
⚡ Rust/WebAssembly image processing library
Stars: ✭ 963 (+2040%)
Mutual labels:  rust-library
Not Yet Awesome Rust
A curated list of Rust code and resources that do NOT exist yet, but would be beneficial to the Rust community.
Stars: ✭ 789 (+1653.33%)
Mutual labels:  rust-library
Rage
A simple, secure and modern encryption tool (and Rust library) with small explicit keys, no config options, and UNIX-style composability.
Stars: ✭ 826 (+1735.56%)
Mutual labels:  rust-library
Simulacrum
A small library for creating mock objects in Rust.
Stars: ✭ 21 (-53.33%)
Mutual labels:  rust-library
Quicksilver
A simple framework for 2D games on desktop and web
Stars: ✭ 710 (+1477.78%)
Mutual labels:  rust-library
Finalfusion Rust
finalfusion embeddings in Rust
Stars: ✭ 35 (-22.22%)
Mutual labels:  rust-library
Ureq
Minimal request library in rust.
Stars: ✭ 545 (+1111.11%)
Mutual labels:  rust-library
Tract
Tiny, no-nonsense, self-contained, Tensorflow and ONNX inference
Stars: ✭ 899 (+1897.78%)
Mutual labels:  rust-library
Run script
Run shell scripts in rust.
Stars: ✭ 42 (-6.67%)
Mutual labels:  rust-library
Reqray
Log call tree summaries after each request for rust programs instrumented with `tracing`.
Stars: ✭ 37 (-17.78%)
Mutual labels:  rust-library
Jsonpath Rs
JSONPath for Rust
Stars: ✭ 31 (-31.11%)
Mutual labels:  rust-library

dtparse

travisci crates.io docs.rs

The fully-featured "even I couldn't understand that" time parser. Designed to take in strings and give back sensible dates and times.

dtparse has its foundations in the dateutil library for Python, which excels at taking "interesting" strings and trying to make sense of the dates and times they contain. A couple of quick examples from the test cases should give some context:

extern crate chrono;
extern crate dtparse;
use chrono::prelude::*;
use dtparse::parse;

assert_eq!(
    parse("2008.12.30"),
    Ok((NaiveDate::from_ymd(2008, 12, 30).and_hms(0, 0, 0), None))
);

// It can even handle timezones!
assert_eq!(
    parse("January 4, 2024; 18:30:04 +02:00"),
    Ok((
        NaiveDate::from_ymd(2024, 1, 4).and_hms(18, 30, 4),
        Some(FixedOffset::east(7200))
    ))
);

And we can even handle fuzzy strings where dates/times aren't the only content if we dig into the implementation a bit!

extern crate chrono;
extern crate dtparse;
use chrono::prelude::*;
use dtparse::Parser;
use std::collections::HashMap;

let mut p = Parser::default();
assert_eq!(
    p.parse(
        "I first released this library on the 17th of June, 2018.",
        None, None,
        true /* turns on fuzzy mode */,
        true /* gives us the tokens that weren't recognized */,
        None, false, &HashMap::new()
    ),
    Ok((
        NaiveDate::from_ymd(2018, 6, 17).and_hms(0, 0, 0),
        None,
        Some(vec!["I first released this library on the ",
                  " of ", ", "].iter().map(|&s| s.into()).collect())
    ))
);

Further examples can be found in the examples directory on international usage.

Usage

dtparse requires a minimum Rust version of 1.28 to build, but is tested on Windows, OSX, BSD, Linux, and WASM. The build is also compiled against the iOS and Android SDK's, but is not tested against them.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].