2 stable releases

1.0.1 Jun 4, 2023
1.0.0 Aug 20, 2022

#150 in Date and time

Download history 194/week @ 2023-12-13 271/week @ 2023-12-20 319/week @ 2023-12-27 242/week @ 2024-01-03 136/week @ 2024-01-10 265/week @ 2024-01-17 148/week @ 2024-01-24 313/week @ 2024-01-31 144/week @ 2024-02-07 262/week @ 2024-02-14 323/week @ 2024-02-21 472/week @ 2024-02-28 168/week @ 2024-03-06 170/week @ 2024-03-13 190/week @ 2024-03-20 239/week @ 2024-03-27

811 downloads per month

MIT license

130KB
2.5K SLoC

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.

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.

  • std - Enables a dependency on the Rust Standard Library. Activating this feature enables implementations of std::error::Error on the error types in this crate and the strftime::io module, which depends on std::io::Write. Activating this feature also activates the alloc feature.
  • alloc - Enables a dependency on the Rust alloc crate. Activating this feature enables the strftime::bytes and stftime::string modules, which depend on alloc::vec::Vec and alloc::string::String. When the alloc feature is enabled, this crate only uses fallible allocation APIs.

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.

No runtime deps