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

time zone conversions fail #4

Closed
zed opened this issue Nov 21, 2012 · 2 comments
Closed

time zone conversions fail #4

zed opened this issue Nov 21, 2012 · 2 comments

Comments

@zed
Copy link
Contributor

zed commented Nov 21, 2012

It works only with the latest timezone for the region. DST transitions, other timezone changes are not handled correctly. Examples:

  • round-trip convert timestamp -> named timezone -> utc
    expected 2002-10-27 05:30:00.000000 UTC+0000
    got        10/27/02 06:30:00.0 +00:00 (UTC)

** convert utc datetime -> named timezone

expected 2002-10-27 01:30:00.000000 EDT-0400
got        10/27/02 01:30:00.0 -05:00 (EST)
  • convert utc to local timezone
    expected 2010-06-06 21:29:07.730000 MSD+0400
    got        06/06/10 21:29:07.730000 +04:00 (MSK)
    expected 2010-12-06 20:29:07.730000 MSK+0300
    got        12/06/10 20:29:07.730000 +04:00 (MSK)
  • date & time in named time zone
    expected 2002-10-27 00:30:00.000000 EDT-0400
    got        10/27/02 00:30:00.0 -05:00 (EST)
  • ambiguous: naive datetime to named timezone - no disambiguation
  • non-existing times
  • time zones in a distant past
    expected 1915-08-04 22:59:59.000000 WMT+0124
    got        08/04/15 22:59:59.0 +01:00 (CET)
    expected 1933-05-15 01:30:00.000000 AMT+0020
    got        05/15/33 01:30:00.0 +01:00 (CET)
    expected 1933-05-15 03:30:00.000000 NST+0120
    got        05/15/33 03:30:00.0 +01:00 (CET)

Examples are from http://pytz.sourceforge.net/

The code to produce the above output https://gist.github.com/4127162

Note: not all of it probably should be fixed but it is useful to be aware that the issues exist.

@crsmithdev
Copy link
Collaborator

Most of the conversion / time zone errors have been fixed in my latest commit. Still remaining are the round-trip errors, and I'm not sure exactly yet what my approach to ambiguous instantiation or non-existent times will be. Addressed a few of the consistency issues in your gist as well.

* round-trip convert timestamp -> named timezone -> utc
    expected 2002-10-27 05:30:00.000000 UTC+0000
    got        10/27/02 06:30:00.0 +00:00 (UTC)
** convert utc datetime -> named timezone
    expected 2002-10-27 01:30:00.000000 EDT-0400
    got        10/27/02 01:30:00.0 -05:00 (EST)
* convert utc to local timezone
    expected 2010-06-06 21:29:07.730000 MSD+0400
    got        06/06/10 21:29:07.730000 +04:00 (MSD)
    expected 2010-12-06 20:29:07.730000 MSK+0300
    got        12/06/10 20:29:07.730000 +03:00 (MSK)
* date & time in named time zone
    expected 2002-10-27 00:30:00.000000 EDT-0400
    got        10/27/02 00:30:00.0 -04:00 (EDT)
* ambiguous: naive datetime to named timezone - no disambiguation
* non-existing times
* time zones in a distant past
    expected 1915-08-04 22:59:59.000000 WMT+0124
    got        08/04/15 22:59:59.0 +01:24 (WMT)
    expected 1933-05-15 01:30:00.000000 AMT+0020
    got        05/15/33 01:30:00.0 +00:20 (AMT)
    expected 1933-05-15 03:30:00.000000 NST+0120
    got        05/15/33 03:30:00.0 +01:20 (NST)

Thanks for the detailed assessment and test code, it was and continues to be extremely helpful.

@zed
Copy link
Contributor Author

zed commented Nov 23, 2012

I've updated the gist to mark (remove) fixed items. Current results:

* round-trip convert timestamp -> named timezone -> utc
    expected 2002-10-27 05:30:00.000000 UTC+0000
    got        10/27/02 06:30:00.0 +00:00 (UTC)
** convert utc datetime -> named timezone
    expected 2002-10-27 01:30:00.000000 EDT-0400
    got        10/27/02 01:30:00.0 -05:00 (EST)
* convert utc to local timezone
* date & time in named time zone
* ambiguous: naive datetime to named timezone - no disambiguation
* non-existing times
* time zones in a distant past
** seconds in utcoffset (pytz also fails here, datetime limitation)
Examples are from http://pytz.sourceforge.net/

The current failures might be due to the bug in dateutils see https://gist.github.com/3838828

krisfremen added a commit to krisfremen/arrow that referenced this issue Jan 18, 2021
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

No branches or pull requests

2 participants