https://github.com/artichoke/strftime-ruby
⏳ Ruby `Time#strftime` parser and formatter
https://github.com/artichoke/strftime-ruby
artichoke ruby rust rust-crate strftime time
Last synced: 6 months ago
JSON representation
⏳ Ruby `Time#strftime` parser and formatter
- Host: GitHub
- URL: https://github.com/artichoke/strftime-ruby
- Owner: artichoke
- License: mit
- Created: 2022-06-25T23:23:12.000Z (over 3 years ago)
- Default Branch: trunk
- Last Pushed: 2025-04-08T00:09:37.000Z (6 months ago)
- Last Synced: 2025-04-08T01:22:41.622Z (6 months ago)
- Topics: artichoke, ruby, rust, rust-crate, strftime, time
- Language: Rust
- Homepage: https://crates.io/crates/strftime-ruby
- Size: 2.08 MB
- Stars: 16
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# strftime-ruby
[](https://github.com/artichoke/strftime-ruby/actions)
[](https://codecov.artichokeruby.org/strftime-ruby/index.html)
[](https://discord.gg/QCe2tp2)
[](https://twitter.com/artichokeruby)
[](https://crates.io/crates/strftime-ruby)
[](https://docs.rs/strftime-ruby)
[](https://artichoke.github.io/strftime-ruby/strftime/)`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.[`time#strftime`]: https://ruby-doc.org/core-3.1.2/Time.html#method-i-strftime
[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:
>
> ```text
> %
> ```## Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
strftime-ruby = "1.3.1"
```## Crate features
All features are enabled by default.
- **std** - Enables a dependency on the Rust Standard Library. Activating this
feature 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].[`std::io::write`]: https://doc.rust-lang.org/std/io/trait.Write.html
[`alloc`]: https://doc.rust-lang.org/alloc/
[`alloc::vec::vec`]: https://doc.rust-lang.org/alloc/vec/struct.Vec.html
[`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.84.0. This version can be bumped in minor
releases.## License
`strftime-ruby` is licensed under the [MIT License](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].[`strftime.c`]: vendor/ruby-3.1.2/strftime.c
[ruby license]: vendor/ruby-3.1.2/COPYING
[bsd 2-clause license]: vendor/ruby-3.1.2/BSDL
[`vendor/readme.md`]: vendor/README.md
[crates.io]: https://crates.io/