예제 #1
0
 def test_rfc3339(self):
     src1 = datetime.now().astimezone()
     a = format_rfc3389(src1)  # 2021-01-10T21:28:24+08:00
     dst1 = parse_iso8601(a)
     # 等于去掉毫秒
     src1 = src1.replace(microsecond=0)
     self.assertEqual(src1, dst1)
예제 #2
0
def parse_gmt(date_str):
    '''
    parse datetime like "2021-01-07T08:53:22.022GMT" to datetime.datetime(2021, 1, 7, 8, 53, 22, 22000)
    :param date_str:
    :return:
    '''
    date_str = date_str.rstrip("GMT")
    return parse_iso8601(date_str)
예제 #3
0
 def test_ios8601(self):
     src1 = datetime.now().astimezone()
     a = src1.isoformat()  # 2021-01-10T21:27:54.287055+08:00
     dst1 = parse_iso8601(a)
     self.assertEqual(src1, dst1)
예제 #4
0
 def test_parse_gmt(self):
     a = "2021-01-07T08:53:22.022GMT"
     a1 = "2021-01-07 08:53:22.022000+00:00"
     b = parse_gmt(a)
     b1 = parse_iso8601(a1)
     self.assertEqual(b, b1)
예제 #5
0
 def test_rfc3339_2(self):
     src1 = datetime.now().astimezone()
     a = format_rfc3389_micro(src1)  # 2021-01-10T21:28:38.490201+08:00
     dst1 = parse_iso8601(a)
     self.assertEqual(src1, dst1)