예제 #1
0
def test_iso8601_datetime_formatters():
    dates = [
        (datetime(2011, 1, 1), "2011-01-01T00:00:00+00:00"),
        (datetime(2011, 1, 1, 23, 59, 59), "2011-01-01T23:59:59+00:00"),
        (datetime(2011, 1, 1, 23, 59, 59, tzinfo=UTC()), "2011-01-01T23:59:59+00:00"),
        (datetime(2011, 1, 1, 23, 59, 59, tzinfo=CET()), "2011-01-01T22:59:59+00:00"),
    ]
    for date_obj, expected in dates:
        yield assert_equal, inputs.iso8601(date_obj), expected
예제 #2
0
파일: fields.py 프로젝트: macnc/PythonL
 def format(self, value):
     try:
         if self.dt_format == "rfc822":
             return inputs.rfc822(value)
         elif self.dt_format == "iso8601":
             return inputs.iso8601(value)
         else:
             raise MarshallingException("Unsupported date format %s" % self.dt_format)
     except AttributeError as ae:
         raise MarshallingException(ae)
예제 #3
0
 def format(self, value):
     try:
         if self.dt_format == 'rfc822':
             return inputs.rfc822(value)
         elif self.dt_format == 'iso8601':
             return inputs.iso8601(value)
         else:
             raise MarshallingException('Unsupported date format %s' %
                                        self.dt_format)
     except AttributeError as ae:
         raise MarshallingException(ae)