Esempio n. 1
0
    def readDate(self):
        """
        Read date from the stream.

        The timezone is ignored as the date is always in UTC.
        """
        ref = self.readInteger(False)

        if ref & REFERENCE_BIT == 0:
            return self.context.getObject(ref >> 1)

        ms = self.stream.read_double()
        result = util.get_datetime(ms / 1000.0)

        if self.timezone_offset is not None:
            result += self.timezone_offset

        self.context.addObject(result)

        return result
Esempio n. 2
0
    def readDate(self):
        """
        Reads a UTC date from the data stream. Client and servers are
        responsible for applying their own timezones.

        Date: C{0x0B T7 T6} .. C{T0 Z1 Z2 T7} to C{T0} form a 64 bit
        Big Endian number that specifies the number of nanoseconds
        that have passed since 1/1/1970 0:00 to the specified time.
        This format is UTC 1970. C{Z1} and C{Z0} for a 16 bit Big
        Endian number indicating the indicated time's timezone in
        minutes.
        """
        ms = self.stream.read_double() / 1000.0
        tz = self.stream.read_short()

        # Timezones are ignored
        d = util.get_datetime(ms)
        self.context.addObject(d)

        return d
Esempio n. 3
0
    def readDate(self):
        """
        Read date from the stream.

        The timezone is ignored as the date is always in UTC.
        """
        ref = self.readInteger(False)

        if ref & REFERENCE_BIT == 0:
            return self.context.getObject(ref >> 1)

        ms = self.stream.read_double()
        result = util.get_datetime(ms / 1000.0)

        if self.timezone_offset is not None:
            result += self.timezone_offset

        self.context.addObject(result)

        return result
Esempio n. 4
0
    def readDate(self):
        """
        Reads a UTC date from the data stream. Client and servers are
        responsible for applying their own timezones.

        Date: C{0x0B T7 T6} .. C{T0 Z1 Z2 T7} to C{T0} form a 64 bit
        Big Endian number that specifies the number of nanoseconds
        that have passed since 1/1/1970 0:00 to the specified time.
        This format is UTC 1970. C{Z1} and C{Z0} for a 16 bit Big
        Endian number indicating the indicated time's timezone in
        minutes.
        """
        ms = self.stream.read_double() / 1000.0
        tz = self.stream.read_short()

        # Timezones are ignored
        d = util.get_datetime(ms)
        self.context.addObject(d)

        return d
Esempio n. 5
0
 def test_preserved_microseconds(self):
     dt = datetime(2009, 3, 8, 23, 30, 47, 770122)
     ts = util.get_timestamp(dt)
     self.assertEqual(util.get_datetime(ts), dt)
Esempio n. 6
0
 def test_get_negative_datetime(self):
     self.assertEqual(util.get_datetime(-31536000), datetime(1969, 1, 1))
Esempio n. 7
0
 def test_get_datetime(self):
     self.assertEqual(util.get_datetime(1194825600), datetime(2007, 11, 12))
Esempio n. 8
0
 def test_preserved_microseconds(self):
     dt = datetime(2009, 3, 8, 23, 30, 47, 770122)
     ts = util.get_timestamp(dt)
     self.assertEqual(util.get_datetime(ts), dt)
Esempio n. 9
0
 def test_get_negative_datetime(self):
     self.assertEqual(util.get_datetime(-31536000), datetime(1969, 1, 1))
Esempio n. 10
0
 def test_get_datetime(self):
     self.assertEqual(util.get_datetime(1194825600), datetime(2007, 11, 12))