datatracker icon indicating copy to clipboard operation
datatracker copied to clipboard

utc_from_string() method replicates Python library code

Open jennifer-richards opened this issue 2 years ago • 0 comments

Describe the issue

The code behind utc_from_string() in ietf/ipr/mail.py should be simplified now that support for python < 3.3 has been dropped.

There are two wrinkles I see:

  1. the datatracker of parsedate_to_datetime() catches ValueError and returns None if it is unable to parse the timezone
  2. the standard parsedate_to_datetime() returns a naive datetime if the string specified -0000

I think both are easy to iron out: for the first, catching ValueError and returning None should preserve the behavior; for the second, the timestamp should be assigned datetime.timezone.utc if its tzinfo is None.

Code of Conduct

jennifer-richards avatar Aug 30 '22 19:08 jennifer-richards