Timelib for Rust
Timelib for Rust is a small Rust wrapper around the timelib library that is used to power PHP and MongoDB.
Installation
You can install with:
Usage
let tz = parse.expect;
strtotime;
strtotime;
View the tests for more examples.
Alpine Linux / musl Support
This library works out-of-the-box on Alpine Linux (musl libc). The build system automatically detects musl targets and:
- Uses pregenerated FFI bindings (avoiding bindgen issues with Alpine's statically-linked Rust)
- Adjusts compiler flags for musl compatibility
- Statically compiles all C code into the binary (no external shared libraries needed besides
libm)
On Alpine Linux:
Optional Features
The generated re2c outputs are bundled and automatically used. If you wish to generate these files yourself, do the following:
- Install
re2c. You can install it easily on all major platforms:- Linux:
apt-get install re2c - Mac:
brew install re2c - Windows:
choco install re2c - From source: re2c.org
- Linux:
- Enable the
re2cfeature:timelib = { version = "0.3", features = ["re2c"] }
Building
Make sure to check out all submodules.
Initial clone:
Post-clone:
&&
You should now be able to run cargo build and cargo test.
If using the re2c feature, make sure to install re2c as described above. i.e. cargo test --features re2c.
Updating the submodule version
Make sure to regenerate the re2c outputs and bindings, then copy them to pregenerated/.
# Clean and build to generate fresh bindings
# Copy generated bindings from build output
# Regenerate re2c outputs
Publishing
Remove --dry-run to publish for real.