def test_datetimeline(): line = DateTimeLine() from datetime import timezone, timedelta tz7 = timezone(timedelta(hours=7), 'GMT +7') tzn4 = timezone(timedelta(hours=-4), 'GMT -4') line.add('dt', [(datetime(2013, 1, 12, 8, tzinfo=tz7), 300), (datetime(2013, 1, 12, 8), 412), (datetime(2013, 1, 12, 8, tzinfo=tzn4), 823)]) line.x_label_rotation = 45 return line.render_response()
def test_datetimeline(): line = DateTimeLine() line.add('dt', [ (datetime(2013, 1, 12, 8, 0), 300), (datetime(2013, 1, 12, 12), 412), (datetime(2013, 2, 22, 12), 823), (datetime(2013, 2, 22, 20), 672) ]) line.x_value_formatter = lambda x: x.strftime("%Y-%m-%d") line.x_label_rotation = 45 return line.render_response()
def test_datetimeline(): line = DateTimeLine() from datetime import timezone, timedelta tz7 = timezone(timedelta(hours=7), 'GMT +7') tzn4 = timezone(timedelta(hours=-4), 'GMT -4') line.add('dt', [(datetime(2013, 1, 12, 8, tzinfo=tz7), 300), (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()
def test_datetimeline(): line = DateTimeLine() from datetime import timezone, timedelta tz7 = timezone(timedelta(hours=7), 'GMT +7') tzn4 = timezone(timedelta(hours=-4), 'GMT -4') line.add( 'dt', [(datetime(2013, 1, 12, 8, tzinfo=tz7), 300), (datetime(2013, 1, 12, 8), 412), (datetime(2013, 1, 12, 8, tzinfo=tzn4), 823)] ) line.x_label_rotation = 45 return line.render_response()
def test_datetimeline(): line = DateTimeLine() from datetime import timezone, timedelta tz7 = timezone(timedelta(hours=7), 'GMT +7') tzn4 = timezone(timedelta(hours=-4), 'GMT -4') line.add('dt', [ (datetime(2013, 1, 12, 8, tzinfo=tz7), 300), (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()
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)]) from datetime import timezone line.x_value_formatter = lambda x: (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 return line.render_response()
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)] ) from datetime import timezone line.x_value_formatter = lambda x: ( 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 return line.render_response()