mirror of
https://github.com/stalwartlabs/mail-parser.git
synced 2026-11-28 16:01:16 +00:00
Change date is_valid check to inclusive range (#15)
* Use inclusive range for is_valid check * Remove year check
This commit is contained in:
@@ -32,14 +32,13 @@ impl DateTime {
|
||||
|
||||
/// Returns true if the date is valid
|
||||
pub fn is_valid(&self) -> bool {
|
||||
(0..23).contains(&self.tz_hour)
|
||||
&& (0..59).contains(&self.tz_minute)
|
||||
&& (1970..2500).contains(&self.year)
|
||||
&& (1..12).contains(&self.month)
|
||||
&& (1..31).contains(&self.day)
|
||||
&& (0..23).contains(&self.hour)
|
||||
&& (0..59).contains(&self.minute)
|
||||
&& (0..59).contains(&self.second)
|
||||
(0..=23).contains(&self.tz_hour)
|
||||
&& (0..=59).contains(&self.tz_minute)
|
||||
&& (1..=12).contains(&self.month)
|
||||
&& (1..=31).contains(&self.day)
|
||||
&& (0..=23).contains(&self.hour)
|
||||
&& (0..=59).contains(&self.minute)
|
||||
&& (0..=59).contains(&self.second)
|
||||
}
|
||||
|
||||
/// Returns the numbers of seconds since 1970-01-01T00:00:00Z (Unix epoch)
|
||||
|
||||
Reference in New Issue
Block a user