Code Monkey home page Code Monkey logo

timelib-rust's Introduction

Timelib for Rust

Crates.io Build Status docs.rs Code Coverage Funding Status

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:

cargo add timelib

Usage

let tz = timelib::Timezone::parse("America/Chicago").expect("Error parsing timezone!");
timelib::strtotime("tomorrow", None, &tz);
timelib::strtotime("next tuesday", Some(1654318823), &tz);

View the tests for more examples.

Optional Features

The genereated re2c outputs are bundled and automatically used. If you wish to generate these files yourself, do the following:

  1. 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
  2. Enable the re2c feature:
    • timelib = { version = "0.3", features = ["re2c"] }

Building

Make sure to check out all submodules.

Initial clone:

git clone --recurse-submodules https://github.com/westy92/timelib-rust

Post-clone:

git submodule init && git submodule update

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

git submodule update --remote

Make sure to regenerate the re2c outputs and copy them to pregenerated/.

cd ext/timelib/
make parse_date.c parse_iso_intervals.c
cp parse_date.c ../../pregenerated/
cp parse_iso_intervals.c ../../pregenerated/

Publishing

Remove --dry-run to publish for real.

cargo publish --dry-run

timelib-rust's People

Contributors

dependabot[bot] avatar westy92 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

timelib-rust's Issues

Remove re2c dependency

Make re2c optional by generating and publishing a file. Allow opting-into re2c with a config?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.