#date-parser #date-time #date #date-format #iso-8601 #formatting #time-formatting

dates-str

A minimal date formatting library. For if you don't need any fancy stuff.

8 stable releases

1.4.4 Mar 24, 2024
1.4.3 Jan 10, 2023
1.1.0 Dec 29, 2022

#213 in Date and time

MIT license

21KB
345 lines

dates-str

A small string date library written in Rust, for Rust


NOTE: DateStr subtraction and add work weird, since all months have 31 days, so use them carefully

An easy crate for using and formatting dates. Works with ISO-8601 formatted dates by default, but you can format your dates with a custom formatter.

Main struct

The main struct of this crate is the DateStr struct. By default and as of now, it only accepts a date in ISO-8601 format. In the near future you will be able to pass any date formatted however you like, as long as you provide a DateFormat.

The DateFormat struct is responsible for parsing dates when they are in non-ISO fromat. Only works for output at the moment.


TODO:

  • Date from custom format.
  • Check if month has correct day number. For example a date not beig the 31st of February
  • Better implementations of Add and Sub traits for DateStr
  • Better README
  • Implement unix epoch, maybe from std::time

docs.rs || crates.io

Dependencies

~0.4–0.8MB
~18K SLoC