Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wtetsu committed Dec 9, 2024
1 parent 87d309e commit 9bdca54
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/epo/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub fn parse_naive_datestr(datestr: &str, parse_settings: &ParseSettings) -> Res
fn parse_datestr(datestr: &str, format: &str) -> Result<DateInfo, String> {
if datestr.len() <= 10 {
if let Ok(date) = NaiveDate::parse_from_str(datestr, format) {
let date_time = date.and_hms(0, 0, 0);
let date_time = date.and_hms_opt(0, 0, 0);
return Ok(DateInfo {
date_time,

Check failure on line 105 in src/epo/date.rs

View workflow job for this annotation

GitHub Actions / build

mismatched types

Check failure on line 105 in src/epo/date.rs

View workflow job for this annotation

GitHub Actions / build

mismatched types
datestr: datestr.to_string(),
Expand Down Expand Up @@ -353,15 +353,15 @@ mod tests {

#[test]
fn test_to_datestr_from_ndt() {
let dt = NaiveDate::from_ymd(1970, 1, 1).and_hms(0, 0, 0);
let dt = NaiveDate::from_ymd(1970, 1, 1).from_ymd_opt(0, 0, 0);
assert_eq!("1970-01-01T00:00:00", to_datestr_from_ndt(dt));

let dt = NaiveDate::from_ymd(2022, 4, 17).and_hms(21, 9, 49);
let dt = NaiveDate::from_ymd(2022, 4, 17).from_ymd_opt(21, 9, 49);
assert_eq!("2022-04-17T21:09:49", to_datestr_from_ndt(dt));

let dt = NaiveDate::from_ymd(2023, 12, 7).and_hms(22, 45, 56);
let dt = NaiveDate::from_ymd(2023, 12, 7).from_ymd_opt(22, 45, 56);
assert_eq!("2023-12-07T22:45:56", to_datestr_from_ndt(dt));

let dt = NaiveDate::from_ymd(2000, 1, 1).and_hms(12, 0, 0);
let dt = NaiveDate::from_ymd(2000, 1, 1).from_ymd_opt(12, 0, 0);
assert_eq!("2000-01-01T12:00:00", to_datestr_from_ndt(dt));
}

0 comments on commit 9bdca54

Please sign in to comment.