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

getting bogus output #30

Closed
foobargeez opened this issue Nov 15, 2019 · 2 comments
Closed

getting bogus output #30

foobargeez opened this issue Nov 15, 2019 · 2 comments

Comments

@foobargeez
Copy link

$> perl
use Date::Manip qw(ParseDate);
print ParseDate("Nov, 2020"), "\n";
2020112000:00:00
$>
@SBECK-github
Copy link
Owner

This is an unfortunate side effect of the flexibility of the Date::Manip parsing. It tries to examine quite a few formats to find a date. In this case, you're parsing
Nov 2020
which it decides is equivalent to
Nov 20/20
or Nov 20, 2020

I'll have to examine the regexps to see if I can tighten them up a bit to avoid this.

@foobargeez
Copy link
Author

Thanks. As this is affecting production, I quickly switched the helper to something like this:

use Time::Moment;
use Time::ParseDate;

my $d = parsedate("22 Aug 1955");
if (defined $d) {
    print Time::Moment->from_epoch($d)->strftime("%Y%m%d"), "\n";
} else {
    print "not valid\n";
}

Not my favorite (double hop) but that's what I quickly found.

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

No branches or pull requests

2 participants