pub struct DateTime {}Expand description
DateTime struct to ease dates and times manipulation.
This module includes date and time types, such as day, hour,ISO 8601 date and time, and many more methods.
Fields§
§day: u8Day of the month: (1-31)
hour: u8Hour of the day: (0-23)
iso_8601: StringISO 8601 date and time: (e.g. “2023-01-01T00:00:00+00:00”)
iso_week: u8ISO week number: (1-53)
microsecond: u32Microsecond: (0-999999)
minute: u8Minute of the hour: (0-59)
month: StringMonth: (e.g. “January”)
now: StringNow object: (e.g. “2023-01-01”)
offset: StringOffset from UTC: (e.g. “+00:00”)
ordinal: u16Ordinal date: (1-366)
second: u8Second of the minute: (0-59)
time: StringTime object: (e.g. “00:00:00”)
tz: StringTz object: (e.g. “UTC”)
weekday: StringWeekday object: (e.g. “Monday”)
year: i32Year object: (e.g. “2023”)
Implementations§
source§impl DateTime
impl DateTime
sourcepub fn new_with_tz(tz: &str) -> Self
pub fn new_with_tz(tz: &str) -> Self
Create a new DateTime object with a custom timezone.
sourcepub fn is_valid_day(input: &str) -> bool
pub fn is_valid_day(input: &str) -> bool
Check if the input is a valid day. 31 is valid. 32 is not valid.
sourcepub fn is_valid_hour(input: &str) -> bool
pub fn is_valid_hour(input: &str) -> bool
Check if the input is a valid hour. 23:59 is valid. 24:00 is not valid.
sourcepub fn is_valid_minute(input: &str) -> bool
pub fn is_valid_minute(input: &str) -> bool
Check if the input is a valid minute. 59 is valid. 60 is not valid.
sourcepub fn is_valid_month(input: &str) -> bool
pub fn is_valid_month(input: &str) -> bool
Check if the input is a valid month. 12 is valid. 13 is not valid.
sourcepub fn is_valid_ordinal(input: &str) -> bool
pub fn is_valid_ordinal(input: &str) -> bool
Check if the input is a valid ordinal date. 366 is valid. 367 is not valid.
sourcepub fn is_valid_second(input: &str) -> bool
pub fn is_valid_second(input: &str) -> bool
Check if the input is a valid second. 59 is valid. 60 is not valid.
sourcepub fn is_valid_time(input: &str) -> bool
pub fn is_valid_time(input: &str) -> bool
Check if the input is a valid time. 23:59:59 is valid. 24:00:00 is not valid.
sourcepub fn is_valid_iso_8601(input: &str) -> bool
pub fn is_valid_iso_8601(input: &str) -> bool
Check if the input is a valid ISO 8601 date and time. 2023-01-01T00:00:00+00:00 is valid. 2023-01-01T00:00:00+00:00:00 is not valid.
sourcepub fn is_valid_iso_week(input: &str) -> bool
pub fn is_valid_iso_week(input: &str) -> bool
Check if the input is a valid ISO week number. 53 is valid. 54 is not valid.
sourcepub fn is_valid_microsecond(input: &str) -> bool
pub fn is_valid_microsecond(input: &str) -> bool
Check if the input is a valid microsecond. 999999 is valid. 1000000 is not valid.
sourcepub fn next_day(&self) -> DateTime
pub fn next_day(&self) -> DateTime
Calculate the next day. Returns a new DateTime struct. The time zone is not updated.
sourcepub fn relative_delta(&self) -> DateTime
pub fn relative_delta(&self) -> DateTime
Calculates the relative delta based on the current date and time
and the fields of the RelativeDelta structure.
Returns the DateTime structure that represents the resulting
date and time.
sourcepub fn previous_day(&self) -> DateTime
pub fn previous_day(&self) -> DateTime
Calculate the previous day.
Returns the DateTime structure that represents the resulting
date and time.