A Rust library for parsing, validating, manipulating, and formatting dates and times 🦀
APACHE-2.0 License
Bot releases are hidden (Show)
Published by sebastienrousseau 11 months ago
A Rust library for parsing, validating, manipulating, and formatting dates and times
Part of the Mini Functions family of libraries.
• Website • Documentation • Report Bug • Request Feature • Contributing Guidelines
The DateTime (DTT)
library is a comprehensive and flexible tool that enables developers to manage dates and times with ease.
It offers a range of functions and data structures that allow you to perform various date and time operations with ease, such as determining the day of the month, hour of the day, working with ISO 8601 date and time formats, and many others.
The library supports the creation of new DateTime objects with either UTC or custom timezone specifications, ensuring that you always have accurate and relevant date and time information. Additionally, it provides a mechanism to validate input dates and times, ensuring that you always have accurate information to work with.
The library DateTime (DTT)
provides date and time types and methods to make it easier to manipulate dates and times. It uses the serde library to derive the Deserialize and Serialize traits to convert the DateTime (DTT)
struct to and from various data formats. It also uses the time and regex crates to deal with time conversions and regular expressions respectively.
The DateTime (DTT)
struct includes fields such as:
Feature | Description |
---|---|
day |
Day of the month: (01-31) |
hour |
Hour of the day: (00-23) |
iso_8601 |
ISO 8601 date and time: (e.g. "2023-01-01T00:00:00+00:00") |
iso_week |
ISO week number: (1-53) |
microsecond |
Microsecond: (0-999999) |
minute |
Minute of the hour: (0-59) |
month |
Month: (e.g. "January") |
now |
Now object: (e.g. "2023-01-01") |
offset |
Offset from UTC: (e.g. "+00:00") |
ordinal |
Ordinal date: (1-366) |
second |
Second of the minute: (0-59) |
time |
Time object: (e.g. "00:00:00") |
tz |
Time zone object: (e.g. "UTC") |
weekday |
Weekday object: (e.g. "Monday") |
year |
Year object: (e.g. "2023") |
Each of which represents different aspects of a date and time.
The DateTime (DTT)
struct has two methods to create instances: new
and new_with_tz
. new
creates a new DateTime (DTT)
object with UTC timezone, and new_with_tz
creates a new DateTime (DTT)
object with a custom timezone.
It also includes a method is_valid_day
which checks if the input string represents a valid day of the week. It also includes a method is_valid_month
which checks if the input string represents a valid month of the year.
Full Changelog: https://github.com/sebastienrousseau/dtt/compare/v0.0.4...v0.0.5