Skip to content

fix custom-formats with timezone - #840

Closed
noviluni wants to merge 2 commits into
masterfrom
fix_custom_formats_with_timezone
Closed

noviluni wants to merge 2 commits into
masterfrom
fix_custom_formats_with_timezone

Conversation

@noviluni

@noviluni noviluni commented Nov 23, 2020 •

Copy link
Copy Markdown
Contributor

Fix ValueError when parsing a date string that already contains timezone info with the custom-formats parser.

fixes: #376, closes: #375

@noviluni
noviluni force-pushed the fix_custom_formats_with_timezone branch from e9359fe to b3ab812 Compare November 23, 2020 09:35
@noviluni
noviluni requested a review from Gallaecio November 23, 2020 09:36
@codecov

codecov Bot commented Nov 23, 2020 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.34%. Comparing base (939e722) to head (b3ab812).
⚠️ Report is 320 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #840   +/-   ##
=======================================
  Coverage   98.33%   98.34%           
=======================================
  Files         231      231           
  Lines        2590     2594    +4     
=======================================
+ Hits         2547     2551    +4     
  Misses         43       43           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +142 to +146
if (
not settings.RETURN_AS_TIMEZONE_AWARE
or (settings.RETURN_AS_TIMEZONE_AWARE
and 'default' == settings.RETURN_AS_TIMEZONE_AWARE and not is_originally_aware)
):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💄

Suggested change
if (
not settings.RETURN_AS_TIMEZONE_AWARE
or (settings.RETURN_AS_TIMEZONE_AWARE
and 'default' == settings.RETURN_AS_TIMEZONE_AWARE and not is_originally_aware)
):
if (
not settings.RETURN_AS_TIMEZONE_AWARE
or (
not is_originally_aware
and settings.RETURN_AS_TIMEZONE_AWARE == 'default'
)
):

logging.config.dictConfig(config)


def is_aware(date_obj):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💄 is_tz_aware or has_tz?

Comment thread tests/test_date.py
self.then_date_was_parsed()
self.then_parsed_period_is('day')
self.then_parsed_date_is(expected_result)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are these tests complete enough?

Given the changes I would expect a test where the date contains a timezone, settings specify a different timezone, and we check that the parsed timezone is the one from the input string, and not the one from the settings.

Also a test about the change to if settings.RETURN_AS_TIMEZONE_AWARE is not True:.

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.

Unable to parse date with UTC offset Unable to use date_formats argument if timezone already found

2 participants