Skip to content

fix: invalid timezone should return err not panic #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TCeason
Copy link

@TCeason TCeason commented Aug 19, 2024

  1. Enhanced time zone check

  2. modify default NaiveDate value set 1970-01-01 not today

Fix Issue: #46

1. Enhanced time zone check

2. modify default NaiveDate value set 1970-01-01 not today
@TCeason
Copy link
Author

TCeason commented Aug 19, 2024

Hi @bspeice , Please take some time to review this pr.

let default_date = default.unwrap_or(&Local::now().naive_local()).date();

let default_ts = NaiveDateTime::new(default_date, NaiveTime::from_hms_opt(0, 0, 0).unwrap());
// If default is none, 1970-01-01 00:00:00 as default value is better.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dateutil parser specifically uses the current time as a reference, I don't want to change that. Please keep the default as-is.

@@ -840,28 +843,54 @@ impl Parser {
}
} else if res.hour.is_some() && (l[i] == "+" || l[i] == "-") {
let signal = if l[i] == "+" { 1 } else { -1 };
let len_li = l[i].len();
// check next index's length
let timezone_len = l[i + 1].len();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the index here? It changes the meaning of the conditional below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants