def test_unpack_highres_date(self): self.assertEquals( (1120153132.3508501, -18000), timestamp.unpack_highres_date('Thu 2005-06-30 12:38:52.350850105 -0500')) self.assertEquals( (1120153132.3508501, 0), timestamp.unpack_highres_date('Thu 2005-06-30 17:38:52.350850105 +0000')) self.assertEquals( (1120153132.3508501, 7200), timestamp.unpack_highres_date('Thu 2005-06-30 19:38:52.350850105 +0200')) self.assertEquals( (1152428738.867522, 19800), timestamp.unpack_highres_date('Sun 2006-07-09 12:35:38.867522001 +0530'))
def test_unpack_highres_date(self): self.assertEqual((1120153132.3508501, -18000), timestamp.unpack_highres_date( 'Thu 2005-06-30 12:38:52.350850105 -0500')) self.assertEqual((1120153132.3508501, 0), timestamp.unpack_highres_date( 'Thu 2005-06-30 17:38:52.350850105 +0000')) self.assertEqual((1120153132.3508501, 7200), timestamp.unpack_highres_date( 'Thu 2005-06-30 19:38:52.350850105 +0200')) self.assertEqual((1152428738.867522, 19800), timestamp.unpack_highres_date( 'Sun 2006-07-09 12:35:38.867522001 +0530'))
def test_random(self): t = time.time() o = local_time_offset() t2, o2 = timestamp.unpack_highres_date(timestamp.format_highres_date(t, o)) self.assertEquals(t, t2) self.assertEquals(o, o2) t -= 24*3600*365*2 # Start 2 years ago o = -12*3600 for count in xrange(500): t += random.random()*24*3600*30 o = ((o/3600 + 13) % 25 - 12)*3600 # Add 1 wrap around from [-12, 12] date = timestamp.format_highres_date(t, o) t2, o2 = timestamp.unpack_highres_date(date) self.assertEquals(t, t2, 'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2-t)) self.assertEquals(o, o2, 'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2-t))
def test_random(self): t = time.time() o = local_time_offset() t2, o2 = timestamp.unpack_highres_date( timestamp.format_highres_date(t, o)) self.assertEqual(t, t2) self.assertEqual(o, o2) t -= 24 * 3600 * 365 * 2 # Start 2 years ago o = -12 * 3600 for count in xrange(500): t += random.random() * 24 * 3600 * 30 o = ((o / 3600 + 13) % 25 - 12) * 3600 # Add 1 wrap around from [-12, 12] date = timestamp.format_highres_date(t, o) t2, o2 = timestamp.unpack_highres_date(date) self.assertEqual( t, t2, 'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2 - t)) self.assertEqual( o, o2, 'Failed on date %r, %s,%s diff:%s' % (date, t, o, t2 - t))
def complete_info(self): """This makes sure that all information is properly split up, based on the assumptions that can be made when information is missing. """ from bzrlib.timestamp import unpack_highres_date # Put in all of the guessable information. if not self.timestamp and self.date: self.timestamp, self.timezone = unpack_highres_date(self.date) self.real_revisions = [] for rev in self.revisions: if rev.timestamp is None: if rev.date is not None: rev.timestamp, rev.timezone = \ unpack_highres_date(rev.date) else: rev.timestamp = self.timestamp rev.timezone = self.timezone if rev.message is None and self.message: rev.message = self.message if rev.committer is None and self.committer: rev.committer = self.committer self.real_revisions.append(rev.as_revision())