Skip to content

Unable to parse date with UTC offset #375

Open

Description

@thernstig

Dateparser is unable to parse this string: Fri Jan 26 16:32:21 +0000 2018

>>> import dateparser
>>> foo = dateparser.parse('Fri Jan 26 16:32:21 +0000 2018')
>>> print(foo)
None

Activity

  1. alertedsnake commented on Oct 22, 2018

    @alertedsnake

    It can if you write it Fri Jan 26 16:32:21 2018 +0000 or 'Fri Jan 26 16:32:21 2018 +0000 - seems weird to not have the TZ offset at the end.

  2. thernstig commented on Oct 23, 2018

    @thernstig
    Author

    @alertedsnake I agree completely, and more people do. But this is Twitter's way to format it. See created_at at this page: https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/tweet-object.html

  3. alertedsnake commented on Oct 23, 2018

    @alertedsnake

    @thernstig wow, how bizarre!

  4. noviluni commented on Nov 23, 2020

    @noviluni
    Contributor

    This should work with date_formats once we merge this: https://github.com/scrapinghub/dateparser/pull/840/files

    >>> dateparser.parse('Fri Jan 26 16:32:21 +0000 2018', date_formats=['%a %b %d %H:%M:%S %z %Y'])
    datetime.datetime(2018, 1, 26, 16, 32, 21, tzinfo=datetime.timezone.utc)
  5. thernstig commented on Nov 23, 2020

    @thernstig
    Author

    @noviluni That is a good approach, that is the approach many time libraries take to let you specify the format. In addition, it seems Twitters API v2 will have a better created_at from the start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions