Skip to content

Commit

Permalink
Add year constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
reknih committed Oct 17, 2023
1 parent 47939cf commit d38cce2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ pub struct DateTime {
pub hour: Option<u8>,
pub minute: Option<u8>,
pub second: Option<u8>,
/// The timezone of this date and time. No assumptions about the timezone or
/// locale should be made if this is `None`.
pub timezone: Option<Timezone>,
}

Expand Down Expand Up @@ -424,6 +426,19 @@ impl DateTime {
}
}

/// Create a new date with a year only.
pub fn year(year: u16) -> Self {
Self {
year,
month: None,
day: None,
hour: None,
minute: None,
second: None,
timezone: None,
}
}

/// Create a new date and time without a timezone.
pub fn date(year: u16, month: u8, day: u8) -> Self {
Self {
Expand Down

0 comments on commit d38cce2

Please sign in to comment.