v1.0.0
Release 1.0.0 of strftime-ruby.
strftime-ruby
is available on crates.io.
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.
API
There are 5 strftime
functions in this crate which vary in the type of format specifier they take and how they write the formatted output:
strftime::buffered::strftime
: Takes a&[u8]
format specifier and writes to the provided byte slice.strftime::fmt::strftime
: Takes a&str
format specifier and writes to the providedcore::fmt::Write
object.strftime::bytes::strftime
: Takes a&[u8]
format specifier and writes to a newly allocatedVec
, which is returned.strftime::string::strftime
: Takes a&str
format specifier and writes to a newly allocatedString
, which is returned.strftime::io::strftime
: Takes a&[u8]
format specifier and writes to the providedstd::io::Write
object.
Allocations
The only routines that allocate in this crate are strftime::bytes::strftime
and strftime::string::strftime
. These routines use fallible allocation APIs from alloc
and return errors to callers.
strftime::fmt::strftime
and strftime::io::strftime
perform no allocations on their own, but the provided writers may allocate.
Cargo Features
strftime-ruby
has alloc and std features. All features are enabled by default.
strftime::buffered::strftime
and strftime::fmt::strftime
are available when this crate is compiled without any features and are usable in a no_std
context.
The alloc feature enables strftime::bytes::strftime
and strftime::string::strftime
.
The std feature enables strftime::io::strftime
.
Test Coverage
strftime-ruby
has 100% line coverage, which is enforced by CI, and is fuzzed regularly.
Composition
strftime-ruby
's APIs take an implementation of its Time
trait to determine the values used with format specifiers. The intent is that time crates across the ecosystem can implement it, making this crate fully interoperable across all time implementations.