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

Adding default TZ of UTC if none specified in the source data #209

Merged

Conversation

BillWeissABK
Copy link
Contributor

Some TLDs (or maybe registrars?) don't provide a timezone for datetimes, which leaves us with two different output types when parsing (reported in #183). This means users of the library have to handle the two paths themselves. This PR adds a timezone of UTC to any that wouldn't have them.

@BillWeissABK
Copy link
Contributor Author

Unsurprisingly this causes a few test failures with domains that don't currently have a TZ set. I find the error output a little weird, so I'm leaving a note here and pulling those test changes into a new commit in case I'm doing something wrong.

❯ python -m unittest
.............google.com.ua 	(expiration_date):	 2019-12-04 00:00:00+02 != 2019-12-04 00:00:00
google.com.ua 	(creation_date):	 ['2002-12-04 00:00:00+02', '2017-07-28 23:53:31+03'] != ['2002-12-04 00:00:00', '2017-07-28 23:53:31']
google.com.ua 	(updated_date):	 2018-11-02 11:29:08+02 != 2018-11-02 11:29:08
google.com.tr 	(expiration_date):	 2019-Aug-22. != 2019-08-22 00:00:00
google.com.tr 	(creation_date):	 2001-Aug-23. != 2001-08-23 00:00:00
google.cl 	(expiration_date):	 2019-11-20 14:48:02 CLST != 2019-11-20 14:48:02
google.cl 	(creation_date):	 2002-10-22 17:48:23 CLST != 2002-10-22 17:48:23
web.de 	(updated_date):	 ['2016-04-11 11:09:54+02:00', '2011-08-10 17:09:10+02:00'] != ['2016-04-11 11:09:54', '2011-08-10 17:09:10']
google.de 	(updated_date):	 2018-03-12 21:44:25+01:00 != 2018-03-12 21:44:25
F...........2024-04-02 09:11:47,435 - whois.whois - ERROR - Error trying to connect to socket: closing socket - [Errno 61] Connection refused
.
======================================================================
FAIL: test_com_allsamples (test.test_parser.TestParser.test_com_allsamples)
Iterate over all of the sample/whois/*.com files, read the data,
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/bweiss/repos/py-whois/test/test_parser.py", line 117, in test_com_allsamples
    self.fail(
AssertionError: 9/357 sample whois attributes were not parsed properly!

----------------------------------------------------------------------
Ran 26 tests in 3.214s

FAILED (failures=1)

@BillWeissABK BillWeissABK force-pushed the default-utc-expirations branch from 2830480 to b43106c Compare April 2, 2024 17:43
@BillWeissABK
Copy link
Contributor Author

Tests run cleanly now, only had to make a couple of changes. Seems ok? Reviews appreciated :)

@BillWeissABK BillWeissABK marked this pull request as ready for review April 2, 2024 18:18
@richardpenman richardpenman merged commit abcf12f into richardpenman:master Apr 3, 2024
3 checks passed
@BillWeissABK BillWeissABK deleted the default-utc-expirations branch April 4, 2024 14:47
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.

2 participants