Esempio n. 1
0
    def test___setstate___without_micros(self):
        ISO = '2001-10-10T00:00:00+02:00'
        dt = DateTime(ISO)
        micros = dt._micros
        dt._millis = dt._micros / 1000
        del dt._micros
        state = dt.__dict__

        dt1 = DateTime()
        dt1.__setstate__(state)
        self.assertEqual(dt1._micros, micros)
Esempio n. 2
0
    tod_int = int(math.floor(tod))
    ms = tod - tod_int
    hr, mn, sc = _calcHMS(tod_int, ms)
    if not tz:
        # Figure out what time zone it is in the local area
        # on the given date.
        x = _calcDependentSecond2(year, month, day, hr, mn, sc)
        tz = self._calcTimezoneName(x, ms)

    return year, month, day, hr, mn, sc, tz


DateTimeKlass._parse = DateTime_parse

if __name__ == '__main__':
    for i in (
            '2007/01/02 12:34:56.789',
            '2007/01/02 12:34:56.789 GMT+0200',
            '2007/01/02 12:34:56.789 JST',
            '2007/01/02 12:34:56.789 +0300',
            '2007/01/02 12:34:56.789 +0430',
            '2007/01/02 12:34:56.789 +1237',
    ):
        a = DateTimeKlass(i)
        b = DateTimeKlass()
        b.__setstate__(a.__getstate__())
        print a, a.__dict__ == b.__dict__
        for i in a.__dict__.keys():
            if a.__dict__[i] != b.__dict__[i]:
                print i, a.__dict__[i], b.__dict__[i]
Esempio n. 3
0

  tod_int = int(math.floor(tod))
  ms = tod - tod_int
  hr,mn,sc = _calcHMS(tod_int, ms)
  if not tz:
    # Figure out what time zone it is in the local area
    # on the given date.
    x = _calcDependentSecond2(year,month,day,hr,mn,sc)
    tz = self._calcTimezoneName(x, ms)

  return year,month,day,hr,mn,sc,tz

DateTimeKlass._parse = DateTime_parse

if __name__ == '__main__':
  for i in ('2007/01/02 12:34:56.789',
            '2007/01/02 12:34:56.789 GMT+0200',
            '2007/01/02 12:34:56.789 JST',
            '2007/01/02 12:34:56.789 +0300',
            '2007/01/02 12:34:56.789 +0430',
            '2007/01/02 12:34:56.789 +1237',
            ):
    a = DateTimeKlass(i)
    b = DateTimeKlass()
    b.__setstate__(a.__getstate__())
    print a, a.__dict__ == b.__dict__
    for i in a.__dict__.keys():
      if a.__dict__[i] != b.__dict__[i]:
        print i, a.__dict__[i], b.__dict__[i]