Пример #1
0
def time_hh_mm(dt):
    """
    Convert a datetime object into a short string of the form HH:MM
    where HH varies from 0 to 23.
    """
    return show_time.format_time(datetime.datetime.utcfromtimestamp(dt),
                                 fmt='HH:mm')
Пример #2
0
 def test_show_time_datetime(self):
     """ users who are not logged-in get ISO 8601 Zulu dates """
     formatted_date = show_time.format_date(utc_dt=0)
     assert formatted_date == '1970-01-01z'
     formatted_time = show_time.format_time(utc_dt=0)
     assert formatted_time == '00:00:00z'
     formatted_date_time = show_time.format_date_time(utc_dt=0)
     assert formatted_date_time == '1970-01-01 00:00:00z'
Пример #3
0
 def test_show_time_datetime_logged_in_local(self):
     """users who are logged-in, unchecked ISO-8601 get dates based on locale and timezone"""
     flaskg.user.valid = True
     flaskg.user.locale = 'en'
     flaskg.user.iso_8601 = False
     flaskg.user.timezone = 'US/Arizona'
     formatted_date = show_time.format_date(utc_dt=0)
     assert formatted_date == 'Dec 31, 1969'
     formatted_time = show_time.format_time(utc_dt=0)
     assert formatted_time == '5:00:00 PM'
     formatted_date_time = show_time.format_date_time(utc_dt=0)
     assert formatted_date_time == 'Dec 31, 1969, 5:00:00 PM'
Пример #4
0
 def test_show_time_datetime_logged_in_utc(self):
     """users who are logged-in, selected UTC timezone and checked ISO-8601 get ISO 8601 Zulu dates"""
     flaskg.user.valid = True
     flaskg.user.timezone = 'UTC'
     flaskg.user.locale = 'en'
     flaskg.user.iso_8601 = True
     formatted_date = show_time.format_date(utc_dt=0)
     assert formatted_date == '1970-01-01z'
     formatted_time = show_time.format_time(utc_dt=0)
     assert formatted_time == '00:00:00z'
     formatted_date_time = show_time.format_date_time(utc_dt=0)
     assert formatted_date_time == '1970-01-01 00:00:00z'