dateparser icon indicating copy to clipboard operation
dateparser copied to clipboard

YYYY/MM/DD HH:mm:ss +TZ such as 2021/06/05 19:36:22 -5:00 not detected

Open buanzo opened this issue 3 years ago • 4 comments

Hi! Love your project!

Whilst checking some binkp servers for TIME strings that should be RFC822 compliant per binkp 1.0 spec, I came across this one which is fairly common, yet dateparser does not support it: 2021/06/05 19:36:22 -5:00 (year, zero-padded month, zero-padded day, 24hs HH:MM:ss and UTC-5 timezone.

I was surprised.

Willing to help if given a bit of orientation on the code.

buanzo avatar Jun 05 '21 22:06 buanzo

Hi @buanzo!

If I'm not wrong, the RFC timezone should be formatted as HHmm without spaces.

That case is already supported:

>>> dateparser.parse('2021/06/05 19:36:22 -0500')
datetime.datetime(2021, 6, 5, 19, 36, 22, tzinfo=<StaticTzInfo 'UTC\-05:00'>)

Alternatively, you can add UTC before -5:00:

>>> dateparser.parse('2021/06/05 19:36:22 UTC-5:00')
datetime.datetime(2021, 6, 5, 19, 36, 22, tzinfo=<StaticTzInfo 'UTC\-05:00'>)

Are you sure this date you indicated is correct and RFC822 compilant? If that's the case, where did you get it?

Thanks! :)

noviluni avatar Jul 24 '21 14:07 noviluni

I am using dateparser for its ability to properly parse a myriad of formats. I got my testing dates off Binkp servers information. Yes, not necessarily super standard compliants... Thanks

On Sat, Jul 24, 2021 at 11:07 AM Marc Hernández @.***> wrote:

Hi @buanzo https://github.com/buanzo!

If I'm not wrong, the RFC timezone should be formatted as HHmm without spaces.

That case is already supported:

dateparser.parse('2021/06/05 19:36:22 -0500') datetime.datetime(2021, 6, 5, 19, 36, 22, tzinfo=<StaticTzInfo 'UTC-05:00'>)

Alternatively, you can add UTC before -5:00:

dateparser.parse('2021/06/05 19:36:22 UTC-5:00')datetime.datetime(2021, 6, 5, 19, 36, 22, tzinfo=<StaticTzInfo 'UTC-05:00'>)

Are you sure this date you indicated is correct and RFC822 compilant? If that's the case, where did you get it?

Thanks! :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/scrapinghub/dateparser/issues/935#issuecomment-886058686, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEHBT56UKKEDNYJS4ODIVDTZLCK7ANCNFSM46FDNZOQ .

buanzo avatar Jul 24 '21 14:07 buanzo

Oh, I didn't close the issue, I mean, I think we could try to support it. I was just curious about the format :)

noviluni avatar Jul 24 '21 15:07 noviluni

I totally understand your curiosity <3 - If you could try to support it, that'd be awesome because it would simplify my code (I hate adding 'special cases'...) but I can most definitely follow that path if required.

On Sat, Jul 24, 2021 at 12:42 PM Marc Hernández @.***> wrote:

Oh, I didn't close the issue, I mean, I think we could try to support it. I was just curious about the format :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/scrapinghub/dateparser/issues/935#issuecomment-886070165, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEHBTYOKO7K562A5MBL3WDTZLNP3ANCNFSM46FDNZOQ .

buanzo avatar Jul 24 '21 15:07 buanzo