Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime-Format-Strptime CPAN distribution.

Report information
The Basics
Id: 119082
Status: resolved
Priority: 0/
Queue: DateTime-Format-Strptime

People
Owner: Nobody in particular
Requestors: EHUELS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Pattern %d-%m-%y matches 2016-11-30
Hi, Using v1.67, I'm iterating through these patterns: '%d-%m-%Y' '%d-%m-%y' '%F' to match the input '2016-11-30' against. It's not clear from the documentation that it's correct for my input to match the second pattern. I know it's definitely *very* unintuitive that it did -- and it obviously invalidates my use case... But from the fact that the parsed date is 2030-11-16, I can only conclude that the second pattern is the one to match. (Also, in the code, I can't find that you're using string or line delimiters to make sure you're matching *exactly that pattern* (and nothing more)). Thanks for having a look at this! Regards, Erik.
Subject: Re: [rt.cpan.org #119082] Pattern %d-%m-%y matches 2016-11-30
Date: Thu, 1 Dec 2016 13:28:03 +1100
To: bug-DateTime-Format-Strptime [...] rt.cpan.org
From: Rick Measham <rick [...] measham.id.au>
Hi Erik, While I no longer maintain this module, I can tell you that it wasn't designed for guessing the format, but for parsing dates when you know the format. If you give the date as 82910-04-13566 and format of %d-%m-%Y then is will looks for \d\d-\d\d-\d\d\d\d and find it. You told it that that was the format of the date you were passing in. While it could include negative look-behinds and negative look-aheads to make sure the previous or next character wasn't a digit, the point of the module isn't to validate a string against a number of patterns. - Rick On 2016-12-01 09:06, Erik Huelsmann via RT wrote: Show quoted text
> Wed Nov 30 17:06:52 2016: Request 119082 was acted upon. > Transaction: Ticket created by EHUELS > Queue: DateTime-Format-Strptime > Subject: Pattern %d-%m-%y matches 2016-11-30 > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: EHUELS@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=119082 > > > > Hi, > > Using v1.67, I'm iterating through these patterns: > > '%d-%m-%Y' > '%d-%m-%y' > '%F' > > to match the input '2016-11-30' against. > > It's not clear from the documentation that it's correct for my input to match the second pattern. I know it's definitely *very* unintuitive that it did -- and it obviously invalidates my use case... > > But from the fact that the parsed date is 2030-11-16, I can only conclude that the second pattern is the one to match. (Also, in the code, I can't find that you're using string or line delimiters to make sure you're matching *exactly that pattern* (and nothing more)). > > Thanks for having a look at this! > > Regards, > > Erik.
-- Message protected for iSite by MailGuard: e-mail anti-virus, anti-spam and content filtering.http://www.mailguard.com.au
Hi Rick, Thanks for the quick response! On Wed Nov 30 21:28:23 2016, rick@measham.id.au wrote: Show quoted text
> Hi Erik, > > While I no longer maintain this module, I can tell you that it wasn't > designed for guessing the format, but for parsing dates when you know > the format.
Yes. I'm aware of that. However, ... Show quoted text
> If you give the date as 82910-04-13566 and format of %d-%m-%Y then is > will looks for \d\d-\d\d-\d\d\d\d and find it. You told it that that > was the format of the date you were passing in.
This is *exactly* what I call guessing the format. Because the input does not exactly match the pattern, yet you're not failing to generate a date. So, my point is not that I expect '2016-11-30' to be parsed. My point is that, when the format '%d-%m-%y' is used, the input should be *rejected* as it is not a valid date of the format '\d\d-\d\d-\d\d'. Anything else would be guessing the format and/or guessing the input's intentions. Show quoted text
> While it could include negative look-behinds and negative look-aheads > to > make sure the previous or next character wasn't a digit, the point of > the module isn't to validate a string against a number of patterns.
No, but wouldn't you say that you're now also matching 'yesterday, 16-11-30'? Which isn't exactly date parsing, but rather date extracting? I want to use the module to parse dates according to a format and reject the input when it doesn't match. To be honest, I am highly surprised that the module introduction mentions something about date-guessing, but it doesn't mention that it'll accept '2222222-15-11111' as a valid date for e.g. a '\d\d-\d\d-\d\d' pattern. I hope the maintainers consider this a bug! Regards, Erik.
Subject: Re: [rt.cpan.org #119082] Pattern %d-%m-%y matches 2016-11-30
Date: Thu, 1 Dec 2016 18:01:13 +1100
To: bug-DateTime-Format-Strptime [...] rt.cpan.org
From: Rick Measham <rick [...] measham.id.au>
Actually, rethinking it, I'd agree that it's a bug. It's not about finding the date within your string. I should stay out of things I'm no longer a part of :D - Rick On 2016-12-01 17:59, Erik Huelsmann via RT wrote: Show quoted text
> Queue: DateTime-Format-Strptime > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=119082 > > > Hi Rick, > > Thanks for the quick response! > > On Wed Nov 30 21:28:23 2016, rick@measham.id.au wrote:
>> Hi Erik, >> >> While I no longer maintain this module, I can tell you that it wasn't >> designed for guessing the format, but for parsing dates when you know >> the format.
> Yes. I'm aware of that. However, ... >
>> If you give the date as 82910-04-13566 and format of %d-%m-%Y then is >> will looks for \d\d-\d\d-\d\d\d\d and find it. You told it that that >> was the format of the date you were passing in.
> This is *exactly* what I call guessing the format. Because the input does not exactly match the pattern, yet you're not failing to generate a date. > > So, my point is not that I expect '2016-11-30' to be parsed. My point is that, when the format '%d-%m-%y' is used, the input should be *rejected* as it is not a valid date of the format '\d\d-\d\d-\d\d'. Anything else would be guessing the format and/or guessing the input's intentions. >
>> While it could include negative look-behinds and negative look-aheads >> to >> make sure the previous or next character wasn't a digit, the point of >> the module isn't to validate a string against a number of patterns.
> No, but wouldn't you say that you're now also matching 'yesterday, 16-11-30'? Which isn't exactly date parsing, but rather date extracting? I want to use the module to parse dates according to a format and reject the input when it doesn't match. > > To be honest, I am highly surprised that the module introduction mentions something about date-guessing, but it doesn't mention that it'll accept '2222222-15-11111' as a valid date for e.g. a '\d\d-\d\d-\d\d' pattern. > > > I hope the maintainers consider this a bug! > > Regards, > > Erik.
-- Message protected for iSite by MailGuard: e-mail anti-virus, anti-spam and content filtering.http://www.mailguard.com.au
Closing this since we have a GitHub issue at https://github.com/houseabsolute/DateTime-Format-Strptime/issues/11