dateparser icon indicating copy to clipboard operation
dateparser copied to clipboard

Fix #403

Open Baviaan opened this issue 2 years ago • 3 comments

The parse function only works with naive times, so this provides timezone information to compute the offset from utc and provide _correct_for_time_frame with the utc time instead of local time as _correct_for_time_frame checks if the time has passed in utc.

This fixes #403

Baviaan avatar Oct 19 '21 17:10 Baviaan

Could you please include a test for the fix?

Gallaecio avatar Oct 19 '21 18:10 Gallaecio

Codecov Report

Merging #1002 (50c3872) into master (8af4f29) will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1002   +/-   ##
=======================================
  Coverage   98.29%   98.29%           
=======================================
  Files         234      234           
  Lines        2694     2697    +3     
=======================================
+ Hits         2648     2651    +3     
  Misses         46       46           
Impacted Files Coverage Δ
dateparser/date_parser.py 93.75% <100.00%> (ø)
dateparser/parser.py 99.01% <100.00%> (+<0.01%) :arrow_up:

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 8af4f29...50c3872. Read the comment docs.

codecov[bot] avatar Oct 19 '21 18:10 codecov[bot]

Thanks for the comments.

  • I have renamed ptz to tz.
  • I passed tz to _correct_for_time_frame to do the shift inside the method. (This looks much better indeed!)
  • I have added two tests that fail on master but pass with these fixes. (One for 'future' and for 'past' prefer_dates_from setting.) I wasn't sure where to put them, they're currently at the bottom of the test_date_parser.py file.

Baviaan avatar Oct 19 '21 22:10 Baviaan