Releases: sebastienrousseau/dtt
DateTime (DTT) 🦀 v0.0.8
Release v0.0.8 - 2024-09-02
DateTime (DTT)
A Rust library for parsing, validating, manipulating, and formatting dates and times.
![Made With Love][made-with-rust] ![Crates.io][crates-badge] ![lib.rs][libs-badge] ![Docs.rs][docs-badge] ![Codecov][codecov-badge]
• Website • Documentation • Report Bug • Request Feature • Contributing Guidelines
Overview
The DateTime (DTT)
library is a comprehensive and flexible tool that enables developers to manage dates and times with ease. It offers a wide range of functions, macros, and data structures for performing date and time operations, such as creating, parsing, validating, and formatting date-time objects.
The library supports the creation of new DateTime
objects with either UTC or custom timezone specifications, providing accurate and relevant date and time information. Additionally, it offers mechanisms for validating input dates and times, ensuring reliable and precise operations.
Features
The DateTime (DTT)
library offers the following features:
-
Core Fields:
datetime
: The date and time in UTC (PrimitiveDateTime
).offset
: The timezone offset in UTC (UtcOffset
).
-
Core Methods:
new()
: Creates a newDateTime
instance with the current UTC time.new_with_tz(tz: &str)
: Creates a newDateTime
object with the specified timezone.new_with_custom_offset(hours: i8, minutes: i8)
: Creates aDateTime
object with a custom UTC offset.from_components(year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, offset: UtcOffset)
: Creates aDateTime
object from individual date and time components.update(&self)
: Updates theDateTime
object to the current date and time.now()
: Returns the currentDateTime
.from_str(s: &str)
: Parses a string into aDateTime
instance (implementation ofFromStr
trait).default()
: Returns the current UTC time as the default value forDateTime
.
-
Parsing and Formatting:
parse(input: &str)
: Parses a date-time string into aDateTime
object.parse_custom_format(input: &str, format: &str)
: Parses a date-time string using a custom format.format(&self, format_str: &str)
: Formats theDateTime
object as a string using the specified format.format_rfc3339(&self)
: Formats theDateTime
as an RFC 3339 string.format_iso8601(&self)
: Formats theDateTime
as an ISO 8601 string.
-
Date-Time Manipulation:
convert_to_tz(&self, new_tz: &str)
: Converts theDateTime
object to a different timezone.unix_timestamp(&self)
: Returns the Unix timestamp of theDateTime
object.add_days(&self, days: i64)
: Adds a specified number of days to theDateTime
.add_months(&self, months: i32)
: Adds a specified number of months to theDateTime
.add_years(&self, years: i32)
: Adds a specified number of years to theDateTime
.sub_months(&self, months: i32)
: Subtracts a specified number of months from theDateTime
.sub_years(&self, years: i32)
: Subtracts a specified number of years from theDateTime
.next_day(&self)
: Returns a newDateTime
instance representing the next day.previous_day(&self)
: Returns a newDateTime
instance representing the previous day.start_of_week(&self)
: Returns a newDateTime
instance at the start of the week.end_of_week(&self)
: Returns a newDateTime
instance at the end of the week.start_of_month(&self)
: Returns a newDateTime
instance at the start of the month.end_of_month(&self)
: Returns a newDateTime
instance at the end of the month.start_of_year(&self)
: Returns a newDateTime
instance at the start of the year.end_of_year(&self)
: Returns a newDateTime
instance at the end of the year.is_within_range(&self, start: &Self, end: &Self)
: Checks if theDateTime
falls within a specific range.duration_since(&self, other: &Self)
: Calculates the duration between twoDateTime
instances.
-
Getters:
year(&self)
: Returns the year.month(&self)
: Returns the month.day(&self)
: Returns the day of the month.hour(&self)
: Returns the hour.minute(&self)
: Returns the minute.second(&self)
: Returns the second.microsecond(&self)
: Returns the microsecond.weekday(&self)
: Returns the weekday.ordinal(&self)
: Returns the day of the year (ordinal).iso_week(&self)
: Returns the ISO week number.offset(&self)
: Returns the UTC offset.
-
Setters:
set_date(&self, year: i32, month: u8, day: u8)
: Sets a new date for theDateTime
instance.set_time(&self, hour: u8, minute: u8, second: u8)
: Sets a new time for theDateTime
instance.
-
Validation:
is_valid_day(day: &str)
: Checks if the input represents a valid day of the month.is_valid_hour(hour: &str)
: Checks if the input represents a valid hour of the day.is_valid_minute(minute: &str)
: Checks if the input represents a valid minute of the hour.is_valid_second(second: &str)
: Checks if the input represents a valid second of the minute.is_valid_month(month: &str)
: Checks if the input represents a valid month of the year.is_valid_year(year: &str)
: Checks if the input represents a valid year.is_valid_microsecond(microsecond: &str)
: Checks if the input represents a valid microsecond.is_valid_ordinal(ordinal: &str)
: Checks if the input represents a valid ordinal day of the year.is_valid_iso_week(week: &str)
: Checks if the input represents a valid ISO week number.is_valid_time(time: &str)
: Checks if the input represents a valid time inHH:MM:SS
format.is_valid_iso_8601(date: &str)
: Checks if the input represents a valid ISO 8601 formatted date.
-
Utility Functions:
format_time_in_timezone(tz: &str, format: &str)
: Formats the current time for a specific timezone.
-
Arithmetic Operations:
Add<Duration>
: Adds aDuration
to theDateTime
instance.Sub<Duration>
: Subtracts aDuration
from theDateTime
instance.
-
Comparison Operations:
PartialOrd
: Allows partial ordering comparisons betweenDateTime
instances.Ord
: Allows total ordering comparisons betweenDateTime
instances.
-
Hashing:
Hash
: AllowsDateTime
instances to be used as keys in hash-based collections.
-
Macros:
dtt_now!()
: Generates the current date and time.dtt_parse!(input)
: Parses a date-time string into aDateTime
object.dtt_print!(datetime)
: Prints aDateTime
object.dtt_vec![]
: Creates a vector.dtt_map!{}
: Creates a map.dtt_assert!
: Asserts conditions during testing.is_valid!
: Checks the validity of various date-time components.dtt_is_valid_function!(func_name)
: Defines a custom validation function.dtt_new_with_tz!(tz)
: Creates a newDateTime
object with a specified timezone.dtt_add_days!(datetime, days)
: Adds days to aDateTime
object.dtt_sub_days!(datetime, days)
: Subtracts days from aDateTime
object.dtt_diff_seconds!(datetime1, datetime2)
: Calculates the difference in seconds between twoDateTime
objects.dtt_diff_days!(datetime1, datetime2)
: Calculates the difference in days between twoDateTime
objects.dtt_clone!
: Creates a deep copy of aDateTime
object.dtt_format!
: Formats aDateTime
object using a provided format string.dtt_create_vec!
: Creates a new vector containing provided elements.dtt_min!
: Returns the minimum of given values.dtt_max!
: Returns the maximum of given values.dtt_join!
: Joins a vector of strings into a single string.dtt_print_vec!
: Prints a vector of elements to the console.
-
Helper Functions:
days_in_month(year: i32, month: u8)
: Determines the number of days in a given month and year.is_leap_year(year: i32)
: Determines if a year is a leap year.
-
Error Handling:
The library provides comprehensive error handling through theDateTimeError
enum, allowing for robust error management in date and time operations. -
Timezone Support:
DateTime (DTT) offers extensive timezone support, allowing for creation and manipulation of date-time objects across different timezones. -
Serialization and Deserialization:
The library supports serialization and deserialization ofDateTime
objects usingserde
, facilitating easy integration with various data formats.
DateTime (DTT) 🦀 v0.0.7
Release v0.0.7 - 2024-09-02
DateTime (DTT)
A Rust library for parsing, validating, manipulating, and formatting dates and times.
![Made With Love][made-with-rust] ![Crates.io][crates-badge] ![lib.rs][libs-badge] ![Docs.rs][docs-badge] ![Codecov][codecov-badge]
• Website • Documentation • Report Bug • Request Feature • Contributing Guidelines
Overview
The DateTime (DTT)
library is a comprehensive and flexible tool that enables developers to manage dates and times with ease. It offers a wide range of functions, macros, and data structures for performing date and time operations, such as creating, parsing, validating, and formatting date-time objects.
The library supports the creation of new DateTime
objects with either UTC or custom timezone specifications, providing accurate and relevant date and time information. Additionally, it offers mechanisms for validating input dates and times, ensuring reliable and precise operations.
Features
The DateTime (DTT)
library offers the following features:
-
Core Fields:
datetime
: The date and time in UTC (PrimitiveDateTime
).offset
: The timezone offset in UTC (UtcOffset
).
-
Core Methods:
new()
: Creates a newDateTime
instance with the current UTC time.new_with_tz(tz: &str)
: Creates a newDateTime
object with the specified timezone.new_with_custom_offset(hours: i8, minutes: i8)
: Creates aDateTime
object with a custom UTC offset.from_components(year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, offset: UtcOffset)
: Creates aDateTime
object from individual date and time components.update(&self)
: Updates theDateTime
object to the current date and time.now()
: Returns the currentDateTime
.from_str(s: &str)
: Parses a string into aDateTime
instance (implementation ofFromStr
trait).default()
: Returns the current UTC time as the default value forDateTime
.
-
Parsing and Formatting:
parse(input: &str)
: Parses a date-time string into aDateTime
object.parse_custom_format(input: &str, format: &str)
: Parses a date-time string using a custom format.format(&self, format_str: &str)
: Formats theDateTime
object as a string using the specified format.format_rfc3339(&self)
: Formats theDateTime
as an RFC 3339 string.format_iso8601(&self)
: Formats theDateTime
as an ISO 8601 string.
-
Date-Time Manipulation:
convert_to_tz(&self, new_tz: &str)
: Converts theDateTime
object to a different timezone.unix_timestamp(&self)
: Returns the Unix timestamp of theDateTime
object.add_days(&self, days: i64)
: Adds a specified number of days to theDateTime
.add_months(&self, months: i32)
: Adds a specified number of months to theDateTime
.add_years(&self, years: i32)
: Adds a specified number of years to theDateTime
.sub_months(&self, months: i32)
: Subtracts a specified number of months from theDateTime
.sub_years(&self, years: i32)
: Subtracts a specified number of years from theDateTime
.next_day(&self)
: Returns a newDateTime
instance representing the next day.previous_day(&self)
: Returns a newDateTime
instance representing the previous day.start_of_week(&self)
: Returns a newDateTime
instance at the start of the week.end_of_week(&self)
: Returns a newDateTime
instance at the end of the week.start_of_month(&self)
: Returns a newDateTime
instance at the start of the month.end_of_month(&self)
: Returns a newDateTime
instance at the end of the month.start_of_year(&self)
: Returns a newDateTime
instance at the start of the year.end_of_year(&self)
: Returns a newDateTime
instance at the end of the year.is_within_range(&self, start: &Self, end: &Self)
: Checks if theDateTime
falls within a specific range.duration_since(&self, other: &Self)
: Calculates the duration between twoDateTime
instances.
-
Getters:
year(&self)
: Returns the year.month(&self)
: Returns the month.day(&self)
: Returns the day of the month.hour(&self)
: Returns the hour.minute(&self)
: Returns the minute.second(&self)
: Returns the second.microsecond(&self)
: Returns the microsecond.weekday(&self)
: Returns the weekday.ordinal(&self)
: Returns the day of the year (ordinal).iso_week(&self)
: Returns the ISO week number.offset(&self)
: Returns the UTC offset.
-
Setters:
set_date(&self, year: i32, month: u8, day: u8)
: Sets a new date for theDateTime
instance.set_time(&self, hour: u8, minute: u8, second: u8)
: Sets a new time for theDateTime
instance.
-
Validation:
is_valid_day(day: &str)
: Checks if the input represents a valid day of the month.is_valid_hour(hour: &str)
: Checks if the input represents a valid hour of the day.is_valid_minute(minute: &str)
: Checks if the input represents a valid minute of the hour.is_valid_second(second: &str)
: Checks if the input represents a valid second of the minute.is_valid_month(month: &str)
: Checks if the input represents a valid month of the year.is_valid_year(year: &str)
: Checks if the input represents a valid year.is_valid_microsecond(microsecond: &str)
: Checks if the input represents a valid microsecond.is_valid_ordinal(ordinal: &str)
: Checks if the input represents a valid ordinal day of the year.is_valid_iso_week(week: &str)
: Checks if the input represents a valid ISO week number.is_valid_time(time: &str)
: Checks if the input represents a valid time inHH:MM:SS
format.is_valid_iso_8601(date: &str)
: Checks if the input represents a valid ISO 8601 formatted date.
-
Utility Functions:
format_time_in_timezone(tz: &str, format: &str)
: Formats the current time for a specific timezone.
-
Arithmetic Operations:
Add<Duration>
: Adds aDuration
to theDateTime
instance.Sub<Duration>
: Subtracts aDuration
from theDateTime
instance.
-
Comparison Operations:
PartialOrd
: Allows partial ordering comparisons betweenDateTime
instances.Ord
: Allows total ordering comparisons betweenDateTime
instances.
-
Hashing:
Hash
: AllowsDateTime
instances to be used as keys in hash-based collections.
-
Macros:
dtt_now!()
: Generates the current date and time.dtt_parse!(input)
: Parses a date-time string into aDateTime
object.dtt_print!(datetime)
: Prints aDateTime
object.dtt_vec![]
: Creates a vector.dtt_map!{}
: Creates a map.dtt_assert!
: Asserts conditions during testing.is_valid!
: Checks the validity of various date-time components.dtt_is_valid_function!(func_name)
: Defines a custom validation function.dtt_new_with_tz!(tz)
: Creates a newDateTime
object with a specified timezone.dtt_add_days!(datetime, days)
: Adds days to aDateTime
object.dtt_sub_days!(datetime, days)
: Subtracts days from aDateTime
object.dtt_diff_seconds!(datetime1, datetime2)
: Calculates the difference in seconds between twoDateTime
objects.dtt_diff_days!(datetime1, datetime2)
: Calculates the difference in days between twoDateTime
objects.dtt_clone!
: Creates a deep copy of aDateTime
object.dtt_format!
: Formats aDateTime
object using a provided format string.dtt_create_vec!
: Creates a new vector containing provided elements.dtt_min!
: Returns the minimum of given values.dtt_max!
: Returns the maximum of given values.dtt_join!
: Joins a vector of strings into a single string.dtt_print_vec!
: Prints a vector of elements to the console.
-
Helper Functions:
days_in_month(year: i32, month: u8)
: Determines the number of days in a given month and year.is_leap_year(year: i32)
: Determines if a year is a leap year.
-
Error Handling:
The library provides comprehensive error handling through theDateTimeError
enum, allowing for robust error management in date and time operations. -
Timezone Support:
DateTime (DTT) offers extensive timezone support, allowing for creation and manipulation of date-time objects across different timezones. -
Serialization and Deserialization:
The library supports serialization and deserialization ofDateTime
objects usingserde
, facilitating easy integration with various data formats.
DateTime (DTT) 🦀 v0.0.7
Release v0.0.7 - 2024-09-02
DateTime (DTT)
A Rust library for parsing, validating, manipulating, and formatting dates and times.
![Made With Love][made-with-rust] ![Crates.io][crates-badge] ![lib.rs][libs-badge] ![Docs.rs][docs-badge] ![Codecov][codecov-badge]
• Website • Documentation • Report Bug • Request Feature • Contributing Guidelines
Overview
The DateTime (DTT)
library is a comprehensive and flexible tool that enables developers to manage dates and times with ease. It offers a wide range of functions, macros, and data structures for performing date and time operations, such as creating, parsing, validating, and formatting date-time objects.
The library supports the creation of new DateTime
objects with either UTC or custom timezone specifications, providing accurate and relevant date and time information. Additionally, it offers mechanisms for validating input dates and times, ensuring reliable and precise operations.
Features
The DateTime (DTT)
library offers the following features:
-
Core Fields:
datetime
: The date and time in UTC (PrimitiveDateTime
).offset
: The timezone offset in UTC (UtcOffset
).
-
Core Methods:
new()
: Creates a newDateTime
instance with the current UTC time.new_with_tz(tz: &str)
: Creates a newDateTime
object with the specified timezone.new_with_custom_offset(hours: i8, minutes: i8)
: Creates aDateTime
object with a custom UTC offset.from_components(year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, offset: UtcOffset)
: Creates aDateTime
object from individual date and time components.update(&self)
: Updates theDateTime
object to the current date and time.now()
: Returns the currentDateTime
.from_str(s: &str)
: Parses a string into aDateTime
instance (implementation ofFromStr
trait).default()
: Returns the current UTC time as the default value forDateTime
.
-
Parsing and Formatting:
parse(input: &str)
: Parses a date-time string into aDateTime
object.parse_custom_format(input: &str, format: &str)
: Parses a date-time string using a custom format.format(&self, format_str: &str)
: Formats theDateTime
object as a string using the specified format.format_rfc3339(&self)
: Formats theDateTime
as an RFC 3339 string.format_iso8601(&self)
: Formats theDateTime
as an ISO 8601 string.
-
Date-Time Manipulation:
convert_to_tz(&self, new_tz: &str)
: Converts theDateTime
object to a different timezone.unix_timestamp(&self)
: Returns the Unix timestamp of theDateTime
object.add_days(&self, days: i64)
: Adds a specified number of days to theDateTime
.add_months(&self, months: i32)
: Adds a specified number of months to theDateTime
.add_years(&self, years: i32)
: Adds a specified number of years to theDateTime
.sub_months(&self, months: i32)
: Subtracts a specified number of months from theDateTime
.sub_years(&self, years: i32)
: Subtracts a specified number of years from theDateTime
.next_day(&self)
: Returns a newDateTime
instance representing the next day.previous_day(&self)
: Returns a newDateTime
instance representing the previous day.start_of_week(&self)
: Returns a newDateTime
instance at the start of the week.end_of_week(&self)
: Returns a newDateTime
instance at the end of the week.start_of_month(&self)
: Returns a newDateTime
instance at the start of the month.end_of_month(&self)
: Returns a newDateTime
instance at the end of the month.start_of_year(&self)
: Returns a newDateTime
instance at the start of the year.end_of_year(&self)
: Returns a newDateTime
instance at the end of the year.is_within_range(&self, start: &Self, end: &Self)
: Checks if theDateTime
falls within a specific range.duration_since(&self, other: &Self)
: Calculates the duration between twoDateTime
instances.
-
Getters:
year(&self)
: Returns the year.month(&self)
: Returns the month.day(&self)
: Returns the day of the month.hour(&self)
: Returns the hour.minute(&self)
: Returns the minute.second(&self)
: Returns the second.microsecond(&self)
: Returns the microsecond.weekday(&self)
: Returns the weekday.ordinal(&self)
: Returns the day of the year (ordinal).iso_week(&self)
: Returns the ISO week number.offset(&self)
: Returns the UTC offset.
-
Setters:
set_date(&self, year: i32, month: u8, day: u8)
: Sets a new date for theDateTime
instance.set_time(&self, hour: u8, minute: u8, second: u8)
: Sets a new time for theDateTime
instance.
-
Validation:
is_valid_day(day: &str)
: Checks if the input represents a valid day of the month.is_valid_hour(hour: &str)
: Checks if the input represents a valid hour of the day.is_valid_minute(minute: &str)
: Checks if the input represents a valid minute of the hour.is_valid_second(second: &str)
: Checks if the input represents a valid second of the minute.is_valid_month(month: &str)
: Checks if the input represents a valid month of the year.is_valid_year(year: &str)
: Checks if the input represents a valid year.is_valid_microsecond(microsecond: &str)
: Checks if the input represents a valid microsecond.is_valid_ordinal(ordinal: &str)
: Checks if the input represents a valid ordinal day of the year.is_valid_iso_week(week: &str)
: Checks if the input represents a valid ISO week number.is_valid_time(time: &str)
: Checks if the input represents a valid time inHH:MM:SS
format.is_valid_iso_8601(date: &str)
: Checks if the input represents a valid ISO 8601 formatted date.
-
Utility Functions:
format_time_in_timezone(tz: &str, format: &str)
: Formats the current time for a specific timezone.
-
Arithmetic Operations:
Add<Duration>
: Adds aDuration
to theDateTime
instance.Sub<Duration>
: Subtracts aDuration
from theDateTime
instance.
-
Comparison Operations:
PartialOrd
: Allows partial ordering comparisons betweenDateTime
instances.Ord
: Allows total ordering comparisons betweenDateTime
instances.
-
Hashing:
Hash
: AllowsDateTime
instances to be used as keys in hash-based collections.
-
Macros:
dtt_now!()
: Generates the current date and time.dtt_parse!(input)
: Parses a date-time string into aDateTime
object.dtt_print!(datetime)
: Prints aDateTime
object.dtt_vec![]
: Creates a vector.dtt_map!{}
: Creates a map.dtt_assert!
: Asserts conditions during testing.is_valid!
: Checks the validity of various date-time components.dtt_is_valid_function!(func_name)
: Defines a custom validation function.dtt_new_with_tz!(tz)
: Creates a newDateTime
object with a specified timezone.dtt_add_days!(datetime, days)
: Adds days to aDateTime
object.dtt_sub_days!(datetime, days)
: Subtracts days from aDateTime
object.dtt_diff_seconds!(datetime1, datetime2)
: Calculates the difference in seconds between twoDateTime
objects.dtt_diff_days!(datetime1, datetime2)
: Calculates the difference in days between twoDateTime
objects.dtt_clone!
: Creates a deep copy of aDateTime
object.dtt_format!
: Formats aDateTime
object using a provided format string.dtt_create_vec!
: Creates a new vector containing provided elements.dtt_min!
: Returns the minimum of given values.dtt_max!
: Returns the maximum of given values.dtt_join!
: Joins a vector of strings into a single string.dtt_print_vec!
: Prints a vector of elements to the console.
-
Helper Functions:
days_in_month(year: i32, month: u8)
: Determines the number of days in a given month and year.is_leap_year(year: i32)
: Determines if a year is a leap year.
-
Error Handling:
The library provides comprehensive error handling through theDateTimeError
enum, allowing for robust error management in date and time operations. -
Timezone Support:
DateTime (DTT) offers extensive timezone support, allowing for creation and manipulation of date-time objects across different timezones. -
Serialization and Deserialization:
The library supports serialization and deserialization ofDateTime
objects usingserde
, facilitating easy integration with various data formats.
DateTime (DTT) 🦀 v0.0.6
Release v0.0.6 - 2024-05-06
DateTime (DTT)
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
Overview 📖
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.
Features ✨
The DateTime (DTT)
struct includes the following fields and methods:
Fields
Feature | Description | Type |
---|---|---|
day |
Day of the month: (1-31) | u8 |
hour |
Hour of the day: (0-23) | u8 |
iso_8601 |
ISO 8601 date and time: (e.g. "2023-01-01T00:00:00+00:00") | String |
iso_week |
ISO week number: (1-53) | u8 |
microsecond |
Microsecond: (0-999999) | u32 |
minute |
Minute of the hour: (0-59) | u8 |
month |
Month: (e.g. "January") | String |
now |
Now object: (e.g. "2023-01-01") | String |
offset |
Offset from UTC: (e.g. "+00:00") | String |
ordinal |
Ordinal date: (1-366) | u16 |
second |
Second of the minute: (0-59) | u8 |
time |
Time object: (e.g. "00:00:00") | String |
tz |
Time zone object: (e.g. "UTC") | String |
weekday |
Weekday object: (e.g. "Monday") | String |
year |
Year object: (e.g. "2023") | i32 |
Methods
new()
: Creates a newDateTime
object with the current UTC time.new_with_tz(tz: &str)
: Creates a newDateTime
object with the specified timezone.is_valid_day(input: &str)
: Checks if the input represents a valid day of the month.is_valid_hour(input: &str)
: Checks if the input represents a valid hour of the day.is_valid_second(input: &str)
: Checks if the input represents a valid second of the minute.is_valid_minute(input: &str)
: Checks if the input represents a valid minute of the hour.is_valid_month(input: &str)
: Checks if the input represents a valid month of the year.is_valid_ordinal(input: &str)
: Checks if the input represents a valid ordinal date.is_valid_time(input: &str)
: Checks if the input represents a valid time.is_valid_iso_week(input: &str)
: Checks if the input represents a valid ISO week number.is_valid_iso_8601(input: &str)
: Checks if the input represents a valid ISO 8601 date and time.is_valid_microsecond(input: &str)
: Checks if the input represents a valid microsecond.update(&mut self)
: Updates theDateTime
object with the current date and time based on the timezone.add_days(&self, days: i32)
: Creates a newDateTime
object with the specified number of days added.next_day(&self)
: Creates a newDateTime
object representing the next day.previous_day(&self)
: Creates a newDateTime
object representing the previous day.relative_delta(&self)
: Creates a newDateTime
object with the relative delta based on the current date and time.format(&self, format_str: &str)
: Formats theDateTime
object as a string using the specified format.
The library also provides various getter methods to extract the individual components of the DateTime
object, such as year()
, month()
, day()
, hour()
, minute()
, second()
, microsecond()
, weekday()
, ordinal()
, iso_8601()
, iso_week()
, time()
, tz()
, and offset()
.
Additionally, the DateTime (DTT)
struct implements the FromStr
trait, allowing for parsing a string into a DateTime
object.
Changelog 📚
Documentation Updates
- Updated the README to reflect recent changes and improvements.
Features
- Improved macros documentation and organization for better usability.
- Version 0.0.6 released.
Bug Fixes
- Fixed issue #57 and updated the README accordingly.
- Resolved error related to the useless use of
format!
.
Refactoring
- Enhanced error handling, better timezone support, and additional utility methods for working with dates and times.
Style Changes
- Improved organization and added more detailed comments.
- Reformatted README for better readability.
Testing
- Added unit tests for
macros.rs
to ensure robustness.
These updates aim to enhance the usability, stability, and documentation of the DateTime library.
What's Changed
- build(deps): bump rustix from 0.36.9 to 0.36.17 by @dependabot in #28
- build(deps): bump anyhow from 1.0.71 to 1.0.75 by @dependabot in #30
- build(deps): bump actions/checkout from 3 to 4 by @dependabot in #29
- build(deps): bump actions/upload-artifact from 3 to 4 by @dependabot in #31
- build(deps): bump time from 0.3.30 to 0.3.31 by @dependabot in #32
- build(deps): bump anyhow from 1.0.75 to 1.0.76 by @dependabot in #33
- build(deps): bump anyhow from 1.0.76 to 1.0.77 by @dependabot in #34
- build(deps): bump anyhow from 1.0.77 to 1.0.78 by @dependabot in #35
- build(deps): bump anyhow from 1.0.78 to 1.0.79 by @dependabot in #36
- build(deps): bump serde from 1.0.193 to 1.0.195 by @dependabot in #38
- build(deps): bump assert_cmd from 2.0.12 to 2.0.13 by @dependabot in #39
- build(deps): bump regex from 1.10.2 to 1.10.3 by @dependabot in #41
- build(deps): bump actions/cache from 3 to 4 by @dependabot in #40
- build(deps): bump serde from 1.0.195 to 1.0.196 by @dependabot in #42
- build(deps): bump time from 0.3.31 to 0.3.32 by @dependabot in #44
- build(deps): bump time from 0.3.32 to 0.3.34 by @dependabot in #46
- build(deps): bump time from 0.3.34 to 0.3.36 by @dependabot in #55
- build(deps): bump anyhow from 1.0.79 to 1.0.82 by @dependabot in #53
- build(deps): bump regex from 1.10.3 to 1.10.4 by @dependabot in #51
- build(deps): bump peaceiris/actions-gh-pages from 3 to 4 by @dependabot in #52
- build(deps): bump serde from 1.0.196 to 1.0.198 by @dependabot in #56
- build(deps): bump serde from 1.0.198 to 1.0.199 by @dependabot in #58
- v0.0.6 by @sebastienrousseau in #60
- Merge pull request #60 from sebastienrousseau/feat/dtt
New Contributors
- @dependabot made their first contribution in #28
Full Changelog: v0.0.5...v0.0.6
DateTime (DTT) 🦀 v0.0.5
Release v0.0.5 - 2023-12-05
DateTime (DTT)
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
Overview 📖
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.
Features ✨
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.
Changelog 📚
What's Changed
- v0.0.5 by @sebastienrousseau in #27
Full Changelog: v0.0.4...v0.0.5
DateTime (DTT) 🦀 v0.0.4
Release v0.0.4 - 2023-05-12
DateTime (DTT)
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
Overview 📖
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.
Features ✨
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.
Changelog 📚
- Merge pull request #4 from sebastienrousseau/feat/dtt
- Feat/dtt by @sebastienrousseau in #4
Full Changelog: v0.0.3...v0.0.4
DateTime (DTT) 🦀 v0.0.3
Release v0.0.3 - 2023-03-09
A Rust library for parsing, validating, manipulating, and formatting dates and times
Welcome to DTT 👋
Website
• Documentation
• Report Bug
• Request Feature
• Contributing Guidelines
Overview 📖
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.
Features ✨
The library DateTime
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
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
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
struct has two methods to create instances: new
and new_with_tz
. new
creates a new DateTime
object with UTC timezone, and new_with_tz
creates a new DateTime
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.
Changelog 📚
What's Changed
- feat(dtt): initial dtt feature branch, macro, ci and doc updates by @sebastienrousseau in #1
- fix(dtt): ci updates and automated release to crates.io by @sebastienrousseau in #2
- fix(dtt): ci tries by @sebastienrousseau in #3
New Contributors
- @sebastienrousseau made their first contribution in #1
Full Changelog: v0.0.2...v0.0.3
DateTime (DTT) 🦀 v0.0.2
A Rust library for parsing, validating, manipulating, and formatting dates and times
Welcome to DTT 👋
Website
• Documentation
• Report Bug
• Request Feature
• Contributing Guidelines
Overview 📖
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.
Features ✨
The library DateTime
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
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
struct includes fields such as day
, hour
, iso_8601
, iso_week
, microsecond
, minute
, month
, now
, offset
, ordinal
, second
, time
, tz
, weekday
, and year
, each of which represent different aspects of a date and time.
The DateTime
struct has two methods to create instances: new
and new_with_tz
. new
creates a new DateTime
object with UTC timezone, and new_with_tz
creates a new DateTime
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.
Installation 📦
It takes just a few minutes to get up and running with dtt
.
Requirements
dtt
requires Rust 1.67.0 or later.
Documentation
ℹ️ Info: Please check out our website for more information and find our documentation on docs.rs, lib.rs and
crates.io.
Usage 📖
To use dtt
in your project, add the following to your Cargo.toml
file:
[dependencies]
dtt = "0.0.2"
Add the following to your main.rs
file:
extern crate dtt;
use dtt::*;
then you can use the functions in your application code.
Examples
DTT
comes with a set of examples that you can use to get started. The examples are located in the examples
directory of the project. To run the examples, clone the repository and run the following command in your terminal from the project root directory.
cargo run --example dtt
Semantic Versioning Policy 🚥
For transparency into our release cycle and in striving to maintain backward compatibility, DTT
follows semantic versioning.
License 📝
The project is licensed under the terms of both the MIT license and the Apache License (Version 2.0).
Contribution 🤝
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Acknowledgements 💙
A big thank you to all the awesome contributors of Mini Functions for their help and support. A special thank you goes to the
Rust Reddit community for providing a lot of useful suggestions on how to improve this project.