Ejemplo n.º 1
0
    def testParse(self):
        timeNum = 784111777
        timeStrs = (
            'Sun, 06 Nov 1994 08:49:37 GMT',
            'Sunday, 06-Nov-94 08:49:37 GMT',
            'Sun Nov  6 08:49:37 1994',

            # Also some non-RFC formats, for good measure.
            'Somefakeday 6 Nov 1994 8:49:37',
            '6 Nov 1994 8:49:37',
            'Sun, 6 Nov 1994 8:49:37',
            '6 Nov 1994 8:49:37 GMT',
            '06-Nov-94 08:49:37',
            'Sunday, 06-Nov-94 08:49:37',
            '06-Nov-94 08:49:37 GMT',
            'Nov  6 08:49:37 1994',
        )
        for timeStr in timeStrs:
            self.assertEquals(http_headers.parseDateTime(timeStr), timeNum)

        # Test 2 Digit date wraparound yuckiness.
        self.assertEquals(
            http_headers.parseDateTime('Monday, 11-Oct-04 14:56:50 GMT'),
            1097506610)
        self.assertEquals(
            http_headers.parseDateTime('Monday, 11-Oct-2004 14:56:50 GMT'),
            1097506610)
Ejemplo n.º 2
0
    def testParse(self):
        timeNum = 784111777
        timeStrs = ('Sun, 06 Nov 1994 08:49:37 GMT',
                    'Sunday, 06-Nov-94 08:49:37 GMT',
                    'Sun Nov  6 08:49:37 1994',

                    # Also some non-RFC formats, for good measure.
                    'Somefakeday 6 Nov 1994 8:49:37',
                    '6 Nov 1994 8:49:37',
                    'Sun, 6 Nov 1994 8:49:37',
                    '6 Nov 1994 8:49:37 GMT',

                    '06-Nov-94 08:49:37',
                    'Sunday, 06-Nov-94 08:49:37',
                    '06-Nov-94 08:49:37 GMT',

                    'Nov  6 08:49:37 1994',
                    )
        for timeStr in timeStrs:
            self.assertEquals(http_headers.parseDateTime(timeStr), timeNum)

        # Test 2 Digit date wraparound yuckiness.
        self.assertEquals(http_headers.parseDateTime(
            'Monday, 11-Oct-04 14:56:50 GMT'), 1097506610)
        self.assertEquals(http_headers.parseDateTime(
            'Monday, 11-Oct-2004 14:56:50 GMT'), 1097506610)
Ejemplo n.º 3
0
 def testRoundtrip(self):
     for i in range(2000):
         time = random.randint(0, 2000000000)
         timestr = http_headers.generateDateTime(time)
         time2 = http_headers.parseDateTime(timestr)
         self.assertEquals(time, time2)
Ejemplo n.º 4
0
 def testRoundtrip(self):
     for i in range(2000):
         time = random.randint(0, 2000000000)
         timestr = http_headers.generateDateTime(time)
         time2 = http_headers.parseDateTime(timestr)
         self.assertEquals(time, time2)