diff --git a/demo/moulinrouge/tests.py b/demo/moulinrouge/tests.py index 1466123..e596ed6 100644 --- a/demo/moulinrouge/tests.py +++ b/demo/moulinrouge/tests.py @@ -946,8 +946,9 @@ def get_test_routes(app): (tz.localize(datetime(2013, 1, 12, 14)), 30), (tz.localize(datetime(2013, 1, 12, 16)), 200) ]) + from datetime import timezone line.x_value_formatter = lambda x: ( - x.replace(tzinfo=pytz.utc).astimezone(tz)).isoformat() + x.replace(tzinfo=timezone.utc).astimezone(tz)).isoformat() # line.x_value_formatter = lambda x: tz.normalize( # x.replace(tzinfo=pytz.utc)).isoformat() line.x_label_rotation = 45 diff --git a/docs/changelog.rst b/docs/changelog.rst index 6976ddf..b2ed7c9 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -12,6 +12,7 @@ Changelog * The `human_readable` option has been removed. Now you have to use the pygal.formatters.human_readable formatter (value_formatter=human_readable instead of human_readable=True) * New chart type: SolidGauge (thanks @chartique #295) * Fix range option for some Charts (#297 #298) +* Fix timezones for DateTimeLine for python 2 (#306, #302) 2.1.1 ===== diff --git a/pygal/test/test_date.py b/pygal/test/test_date.py index 5950700..680ba3e 100644 --- a/pygal/test/test_date.py +++ b/pygal/test/test_date.py @@ -172,4 +172,5 @@ def test_utc_timestamping(): datetime(1999, 12, 31, 23, 59, 59), datetime(2000, 1, 1, 0, 0, 0) ): - assert datetime.utcfromtimestamp(timestamp(d)) == d + assert datetime.utcfromtimestamp( + timestamp(d)) - d < timedelta(microseconds=10)