Parses a date of the form `1997-01-31`
(&self)
| 67 | |
| 68 | /// Parses a date of the form `1997-01-31` |
| 69 | fn date(&self) -> Option<NaiveDate> { |
| 70 | if self.mask & 0b1111111111 != 0b1101101111 || !self.test(4, b'-') || !self.test(7, b'-') { |
| 71 | return None; |
| 72 | } |
| 73 | |
| 74 | let year = self.digits[0] as u16 * 1000 |
| 75 | + self.digits[1] as u16 * 100 |
| 76 | + self.digits[2] as u16 * 10 |
| 77 | + self.digits[3] as u16; |
| 78 | |
| 79 | let month = self.digits[5] * 10 + self.digits[6]; |
| 80 | let day = self.digits[8] * 10 + self.digits[9]; |
| 81 | |
| 82 | NaiveDate::from_ymd_opt(year as _, month as _, day as _) |
| 83 | } |
| 84 | |
| 85 | /// Parses a time of any of forms |
| 86 | /// - `09:26:56` |