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

Fix milliseconds parsing #572

Merged
merged 10 commits into from
Apr 29, 2020
Merged

Fix milliseconds parsing #572

merged 10 commits into from
Apr 29, 2020

Conversation

d10xa
Copy link
Contributor

@d10xa d10xa commented Oct 5, 2019

print(dateparser.date.get_date_from_timestamp(u'1570308760263', None).microsecond)
0

@codecov
Copy link

codecov bot commented Oct 17, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@952e79a). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #572   +/-   ##
=========================================
  Coverage          ?   95.21%           
=========================================
  Files             ?      302           
  Lines             ?     2507           
  Branches          ?        0           
=========================================
  Hits              ?     2387           
  Misses            ?      120           
  Partials          ?        0
Impacted Files Coverage Δ
dateparser/timezones.py 100% <ø> (ø)
dateparser/freshness_date_parser.py 98.94% <ø> (ø)
dateparser/data/date_translation_data/nb.py 100% <ø> (ø)
dateparser/parser.py 98.89% <ø> (ø)
dateparser/utils/strptime.py 100% <ø> (ø)
dateparser/languages/locale.py 98.65% <100%> (ø)
dateparser/date.py 98% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 952e79a...22e68fe. Read the comment docs.

@Gallaecio
Copy link
Member

I think you may be over complicating your implementation. I think it may be better to modify RE_SEARCH_TIMESTAMP to match the timestamp with capture groups for the different relevant numbers here (e.g. r'^(\d{10})(\d{3})?(\d{3})?$'), and work with the captured groups.

As for tests, you should be able to simply extend the existing test_parse_timestamp test with new inputs and outputs.

dateparser/date.py Outdated Show resolved Hide resolved
dateparser/date.py Outdated Show resolved Hide resolved
@d10xa d10xa requested a review from Gallaecio January 29, 2020 12:48
@Gallaecio
Copy link
Member

Co-Authored-By: Adrián Chaves <adrian@chaves.io>
Copy link
Collaborator

@noviluni noviluni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job @d10xa ! 😄

@noviluni noviluni merged commit 0685176 into scrapinghub:master Apr 29, 2020
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 this pull request may close these issues.

3 participants