Skip to content
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

Would you accept a PR to reorder the format strings used in date string parsing? #53

Closed
atc0005 opened this issue Nov 8, 2022 · 1 comment · Fixed by #54
Closed

Comments

@atc0005
Copy link
Contributor

atc0005 commented Nov 8, 2022

@likexian

First, many thanks for this and the whois library. Both are appreciated.


This block:

whois-parser/util.go

Lines 116 to 152 in 81fca9d

func parseDateString(dateString string) (time.Time, error) {
formats := [...]string{
"2006-01-02T15:04:05Z",
"2006-01-02",
"2006-01-02 15:04:05",
"2006. 01. 02.",
"02-Jan-2006",
"02/01/2006 15:04:05",
"02.01.2006",
"02-01-2006",
"02.01.2006 15:04:05",
"02.1.2006 15:04:05",
"2.1.2006 15:04:05",
"2006-01-02 15:04:05-07",
"02-Jan-2006 15:04:05",
"January _2 2006",
"02/01/2006",
"01/02/2006",
"2006-01-02 15:04:05 MST",
"2006-Jan-02",
"2006-Jan-02.",
"2006-01-02 15:04:05 (MST+3)",
time.ANSIC,
time.UnixDate,
time.RubyDate,
time.RFC822,
time.RFC822Z,
time.RFC850,
time.RFC1123,
time.RFC1123Z,
time.RFC3339,
time.RFC3339Nano,
time.Stamp,
time.StampMilli,
time.StampMicro,
time.StampNano,
}

currently attempts to perform date string parsing using a mix of common date string formats.

I'd like to reorder them so that the more specific date formats with time components are attempted first before attempts to use the less precise date-only formats are tried.

Would you accept a PR that makes those changes?

@likexian
Copy link
Owner

likexian commented Nov 9, 2022

Hello @atc0005
Thanks for your feedback, I do accept it, feel free to open a PR.


If you think this repository is helpful, please share it with friends, thanks.

atc0005 added a commit to atc0005/whois-parser that referenced this issue Nov 9, 2022
Order date string formats so that formats containing time
components are tried first before attempting to use the
date-only formats.

Updated doc comment to reflect intent of format string order.

refs likexianGH-53
atc0005 added a commit to atc0005/whois-parser that referenced this issue Nov 9, 2022
Order date string formats so that formats containing time
components are tried first before attempting to use the
date-only formats.

Updated doc comment to reflect intent of format string order.

refs likexianGH-53
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 a pull request may close this issue.

2 participants