Skip to content

Commit

Permalink
Add a pytz test
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Feb 26, 2016
1 parent ee066cd commit a5bede5
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion demo/moulinrouge/tests.py
Expand Up @@ -931,7 +931,25 @@ def test_datetimeline():
(datetime(2013, 1, 12, 8), 412),
(datetime(2013, 1, 12, 8, tzinfo=tzn4), 823)
])
# line.x_value_formatter = lambda x: x.isoformat() # strftime("%Y-%m-%d")
line.x_label_rotation = 45
return line.render_response()

@app.route('/test/datetimeline_with_pytz')
def test_datetimeline_with_pytz():
import pytz
tz = pytz.timezone('US/Eastern')

line = DateTimeLine()
line.add('dt', [
(tz.localize(datetime(2013, 1, 12, 8)), 300),
(tz.localize(datetime(2013, 1, 12, 10)), 600),
(tz.localize(datetime(2013, 1, 12, 14)), 30),
(tz.localize(datetime(2013, 1, 12, 16)), 200)
])
line.x_value_formatter = lambda x: (
x.replace(tzinfo=pytz.utc).astimezone(tz)).isoformat()
# line.x_value_formatter = lambda x: tz.normalize(
# x.replace(tzinfo=pytz.utc)).isoformat()
line.x_label_rotation = 45
return line.render_response()

Expand Down

0 comments on commit a5bede5

Please sign in to comment.