Exemplo n.º 1
0
 def test_extended(self):
     fmt = lambda x: format.format_datetime(x, '%q', self.langinfo)
     dt = datetime.datetime(2005, 1, 1)
     assert fmt(dt) == '1'
     dt = datetime.datetime(2005, 3, 1)
     assert fmt(dt) == '1'
     dt = datetime.datetime(2005, 4, 1)
     assert fmt(dt) == '2'
Exemplo n.º 2
0
 def test_custom(self):
     self.langinfo['d_t_fmt_1'] = 'Q%q %Y'
     fmt = lambda x: format.format_datetime(x, '%1', self.langinfo)
     dt = datetime.datetime(2005, 1, 1)
     assert fmt(dt) == 'Q1 2005'
     dt = datetime.datetime(2005, 3, 1)
     assert fmt(dt) == 'Q1 2005'
     dt = datetime.datetime(2005, 4, 1)
     assert fmt(dt) == 'Q2 2005'
Exemplo n.º 3
0
 def format_datetime(self, datetime, format='%c', **kwargs):
     """Format datetime 'dt' according to `format'."""
     if kwargs:
         conv = self.localeconv().copy()
         conv.update(kwargs)
     else:
         conv = self.localeconv()
     result = locfmt.format_datetime(datetime, format, conv)
     return result
Exemplo n.º 4
0
 def test_basic(self):
     for object,fmt,result in self.data:
         if isinstance(object, datetime.date):
             assert format.format_date(object, fmt,
                                       self.langinfo) == result
         elif isinstance(object, datetime.time):
             assert format.format_time(object, fmt,
                                       self.langinfo) == result
         elif isinstance(object, datetime.datetime):
             assert format.format_datetime(object, fmt,
                                           self.langinfo) == result