def _site(user, app, context): info = '' if context.method=='post': title = context.get_argument('title') subtitle = context.get_argument('subtitle') date_format = context.get_argument('date_format') time_format = context.get_argument('time_format') tz = context.get_argument('time_zone') ss = tz.split(',', 3) siteconfig.set_site_settings( title=title, subtitle=subtitle, date_format=date_format, time_format=time_format, tz_h_offset=int(ss[0]), tz_m_offset=int(ss[1]), tz_dst=int(ss[2]), tz_name=ss[3] ) info = 'Site configuration saved.' site = siteconfig.get_site_settings(False) tz = site.get_tzinfo() now = runtime.convert_datetime(datetime.datetime.now(), tz) return { '__view__' : 'manage_site', 'info' : info, 'site' : site, 'date_formats' : siteconfig.date_format_samples(now), 'time_formats' : siteconfig.time_format_samples(now), 'timezones' : runtime.get_timezone_list(), }
def test_time_format_samples(self): dt = datetime(2008, 2, 21, 13, 20, 59) self.assertEquals([ ('%H:%M:%S', '13:20:59'), ('%H:%M', '13:20'), ('%I:%M:%S %p', '01:20:59 PM'), ('%I:%M %p', '01:20 PM'), ], siteconfig.time_format_samples(dt))
def test_time_format_samples(self): dt = datetime(2008, 2, 21, 13, 20, 59) self.assertEquals( [("%H:%M:%S", "13:20:59"), ("%H:%M", "13:20"), ("%I:%M:%S %p", "01:20:59 PM"), ("%I:%M %p", "01:20 PM")], siteconfig.time_format_samples(dt), )