pub struct DateTime { /* private fields */ }Expand description
Date and time representation used across RTC drivers.
This type represents calendar date and time in a general-purpose way, independent of any specific RTC hardware.
- Validates that
year >= 1970 - Other limits (e.g., 2000-2099) must be enforced by individual drivers
Implementations§
Source§impl DateTime
impl DateTime
Sourcepub fn new(
year: u16,
month: u8,
day_of_month: u8,
hour: u8,
minute: u8,
second: u8,
) -> Result<Self, DateTimeError>
pub fn new( year: u16, month: u8, day_of_month: u8, hour: u8, minute: u8, second: u8, ) -> Result<Self, DateTimeError>
Create a new DateTime instance with validation.
§Errors
Returns a DateTimeError if any component is out of valid range.
Sourcepub fn validate(&self) -> Result<(), DateTimeError>
pub fn validate(&self) -> Result<(), DateTimeError>
Sourcepub fn day_of_month(&self) -> u8
pub fn day_of_month(&self) -> u8
Get the day of the month (1-31).
Sourcepub fn set_year(&mut self, year: u16) -> Result<(), DateTimeError>
pub fn set_year(&mut self, year: u16) -> Result<(), DateTimeError>
Set year with validation.
Re-validates the day in case of leap-year or February issues.
Sourcepub fn set_month(&mut self, month: u8) -> Result<(), DateTimeError>
pub fn set_month(&mut self, month: u8) -> Result<(), DateTimeError>
Set month with validation.
Re-validates the day in case month/day mismatch occurs.
Sourcepub fn set_day_of_month(
&mut self,
day_of_month: u8,
) -> Result<(), DateTimeError>
pub fn set_day_of_month( &mut self, day_of_month: u8, ) -> Result<(), DateTimeError>
Set day with validation.
Sourcepub fn set_minute(&mut self, minute: u8) -> Result<(), DateTimeError>
pub fn set_minute(&mut self, minute: u8) -> Result<(), DateTimeError>
Set minute with validation.
Sourcepub fn set_second(&mut self, second: u8) -> Result<(), DateTimeError>
pub fn set_second(&mut self, second: u8) -> Result<(), DateTimeError>
Set second with validation.
Sourcepub fn calculate_weekday(&self) -> Result<Weekday, DateTimeError>
pub fn calculate_weekday(&self) -> Result<Weekday, DateTimeError>
Calculate weekday for this DateTime
Trait Implementations§
impl Copy for DateTime
impl Eq for DateTime
impl StructuralPartialEq for DateTime
Auto Trait Implementations§
impl Freeze for DateTime
impl RefUnwindSafe for DateTime
impl Send for DateTime
impl Sync for DateTime
impl Unpin for DateTime
impl UnwindSafe for DateTime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more