How to use the freezer.utils.utils.DateTime function in freezer

To help you get started, we’ve selected a few freezer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / freezer / tests / unit / utils / test_utils.py View on Github external
def test_initialize_string(self):
        d = utils.DateTime('2015-03-07T17:47:44')
        # ensure that timestamp is check with appropriate timezone offset
        assert (1425750464+time.timezone) == d.timestamp
        assert '2015-03-07 17:47:44' == '{}'.format(d)
github openstack / freezer / tests / unit / utils / test_utils.py View on Github external
def test_sub(self):
        d2 = datetime.datetime(2015, 3, 7, 18, 18, 38, 508411)
        ts2 = utils.DateTime(d2)
        assert '0:30:53.791612' == '{}'.format(ts2 - self.datetime)
github openstack / freezer / tests / unit / utils / test_utils.py View on Github external
def test_factory(self):
        new_time = utils.DateTime.now()
        assert isinstance(new_time, utils.DateTime)
github openstack / freezer / tests / unit / utils / test_utils.py View on Github external
def test_factory(self):
        new_time = utils.DateTime.now()
        assert isinstance(new_time, utils.DateTime)
github openstack / freezer / freezer / scheduler / shell.py View on Github external
table = prettytable.PrettyTable(fields)
    l = list_func()
    offset = 0
    while l:
        offset += len(l)
        for doc in l:
            metadata_doc = doc['backup_metadata']
            timestamp = int(metadata_doc.get('time_stamp', 0))
            if args.long:
                row = [doc['backup_uuid'],
                       metadata_doc.get('job_id', ''),
                       metadata_doc.get('client_id', ''),
                       metadata_doc.get('container', ''),
                       metadata_doc.get('hostname', ''),
                       metadata_doc.get('backup_name', ''),
                       str(freezer_utils.DateTime(timestamp)),
                       metadata_doc.get('curr_backup_level', ''),
                       metadata_doc.get('fs_real_path', '')]
            else:
                row = [doc['backup_uuid'],
                       metadata_doc.get('container', ''),
                       metadata_doc.get('backup_name', ''),
                       str(freezer_utils.DateTime(timestamp)),
                       metadata_doc.get('curr_backup_level', ''),
                       metadata_doc.get('fs_real_path', '')]
            table.add_row(row)
        l = list_func(offset=offset)
    print(table)
github openstack / freezer / freezer / utils / utils.py View on Github external
def __sub__(self, other):
        assert isinstance(other, DateTime)
        return self.date_time - other.date_time  # return timedelta
github openstack / freezer / freezer / utils / utils.py View on Github external
def now():
        return DateTime(datetime.datetime.now())