artichoke / strftime-ruby

⏳ Ruby `Time#strftime` parser and formatter
https://crates.io/crates/strftime-ruby
MIT License
12 stars 0 forks source link
artichoke ruby rust rust-crate strftime time

strftime-ruby

GitHub Actions Code Coverage Discord Twitter
Crate API API trunk

strftime-ruby is a Ruby 3.1.2 compatible implementation of the Time#strftime method. The strftime routines provided by this crate are [POSIX-compatible], except for intentionally ignoring the E and O modified conversion specifiers.

[posix-compatible]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html

Formats time according to the directives in the given format string.

The directives begin with a percent (%) character. Any text not listed as a directive will be passed through to the output string.

The directive consists of a percent (%) character, zero or more flags, optional minimum field width, optional modifier and a conversion specifier as follows:

%<flags><width><modifier><conversion>

Usage

Add this to your Cargo.toml:

[dependencies]
strftime-ruby = "1.0.1"

Crate features

All features are enabled by default.

[alloc::string::string]: https://doc.rust-lang.org/alloc/string/struct.String.html [fallible allocation apis]: https://doc.rust-lang.org/alloc/vec/struct.Vec.html#method.try_reserve

Minimum Supported Rust Version

This crate requires at least Rust 1.58.0. This version can be bumped in minor releases.

License

strftime-ruby is licensed under the MIT License (c) Ryan Lopopolo and x-hgg-x.

This repository includes a vendored copy of strftime.c from Ruby 3.1.2, which is licensed under the Ruby license or BSD 2-clause license. See vendor/README.md for more details. These sources are not distributed on crates.io.