当前位置: 首页>>代码示例>>Python>>正文


Python dateutils.local_tz函数代码示例

本文整理汇总了Python中pulp.common.dateutils.local_tz函数的典型用法代码示例。如果您正苦于以下问题:Python local_tz函数的具体用法?Python local_tz怎么用?Python local_tz使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了local_tz函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_tz_specified

 def test_tz_specified(self):
     """
     Ensure that if the tz is already specified, it is used.
     """
     dt = datetime.datetime.now(dateutils.local_tz())
     new_date = dateutils.ensure_tz(dt)
     self.assertEquals(new_date.tzinfo, dateutils.utc_tz())
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:7,代码来源:test_dateutils.py

示例2: assert_last_sync_time

def assert_last_sync_time(time_in_iso):
    now = datetime.datetime.now(dateutils.local_tz())
    finished = dateutils.parse_iso8601_datetime(time_in_iso)

    # Compare them within a threshold since they won't be exact
    difference = now - finished
    return difference.seconds < 2
开发者ID:jdob,项目名称:pulp,代码行数:7,代码来源:test_repo_publish_manager.py

示例3: add_result

def add_result(repo_id, offset):
    started = datetime.datetime.now(dateutils.local_tz())
    completed = started + datetime.timedelta(days=offset)
    r = RepoSyncResult.expected_result(repo_id, 'foo', 'bar', dateutils.format_iso8601_datetime(started),
                                       dateutils.format_iso8601_datetime(completed), 1, 1, 1, '', '',
                                       RepoSyncResult.RESULT_SUCCESS)
    RepoSyncResult.get_collection().save(r, safe=True)
开发者ID:cliffy94,项目名称:pulp,代码行数:7,代码来源:test_repo_sync_manager.py

示例4: test_ensure_tz_specified

 def test_ensure_tz_specified(self):
     """
     If the timezone is specified, the result should be the same.
     """
     dt = datetime.datetime.now(dateutils.local_tz())
     new_date = Repository._ensure_tz_specified(dt)
     self.assertEquals(new_date.tzinfo, dateutils.utc_tz())
开发者ID:nbetm,项目名称:pulp,代码行数:7,代码来源:test_model.py

示例5: _now_timestamp

def _now_timestamp():
    """
    @return: timestamp suitable for indicating when a publish completed
    @rtype:  str
    """
    now = datetime.datetime.now(dateutils.local_tz())
    now_in_iso_format = dateutils.format_iso8601_datetime(now)
    return now_in_iso_format
开发者ID:fdammeke,项目名称:pulp,代码行数:8,代码来源:publish.py

示例6: test_last_publish

    def test_last_publish(self):
        # Setup
        self.publish_manager.publish(self.group_id, self.distributor_id)

        # Test
        last_publish = self.publish_manager.last_publish(self.group_id, self.distributor_id)

        # Verify
        now = datetime.datetime.now(dateutils.local_tz())
        difference = now - last_publish
        self.assertTrue(difference.seconds < 2)
开发者ID:stpierre,项目名称:pulp,代码行数:11,代码来源:test_repo_group_publish_manager.py

示例7: test_last_publish

    def test_last_publish(self):
        # Setup
        distributor, instance, config = self.publish_manager._get_distributor_instance_and_config(self.group_id, self.distributor_id)
        self.publish_manager.publish(self.group_id, self.distributor_id, distributor, instance, config)

        # Test
        last_publish = self.publish_manager.last_publish(self.group_id, self.distributor_id)

        # Verify
        now = datetime.datetime.now(dateutils.local_tz())
        difference = now - last_publish
        self.assertTrue(difference.seconds < 2)
开发者ID:bartwo,项目名称:pulp,代码行数:12,代码来源:test_repo_group_publish_manager.py

示例8: cull_history

    def cull_history(self, lifetime):
        '''
        Deletes all consumer history entries that are older than the given lifetime.

        @param lifetime: length in days; history entries older than this many days old
                         are deleted in this call
        @type  lifetime: L{datetime.timedelta}
        '''
        now = datetime.datetime.now(dateutils.local_tz())
        limit = dateutils.format_iso8601_datetime(now - lifetime)
        spec = {'timestamp': {'$lt': limit}}
        self.collection.remove(spec, safe=False)
开发者ID:jeremycline,项目名称:pulp,代码行数:12,代码来源:history.py

示例9: add_result

def add_result(repo_id, dist_id, offset):
    started = datetime.datetime.now(dateutils.local_tz())
    completed = started + datetime.timedelta(days=offset)
    r = RepoPublishResult.expected_result(
        repo_id,
        dist_id,
        "bar",
        dateutils.format_iso8601_datetime(started),
        dateutils.format_iso8601_datetime(completed),
        "test-summary",
        "test-details",
        RepoPublishResult.RESULT_SUCCESS,
    )
    RepoPublishResult.get_collection().insert(r, safe=True)
开发者ID:jdob,项目名称:pulp,代码行数:14,代码来源:test_repo_publish_manager.py

示例10: unpickle_timezone_information

def unpickle_timezone_information(offset):
    """
    Unpickle timezone information
    @param offset: timezone utc offset
    """
    utc_tz = dateutils.utc_tz()
    utc_offset = utc_tz.utcoffset(None)
    if offset == utc_offset:
        return utc_tz
    local_tz = dateutils.local_tz()
    local_offset = local_tz.utcoffset(None)
    if offset == local_offset:
        return local_tz
    offset_hours = offset.days * 24
    offset_minutes = offset.seconds / 60
    return isodate.FixedOffset(offset_hours, offset_minutes)
开发者ID:ashcrow,项目名称:pulp,代码行数:16,代码来源:pickling.py

示例11: test_datetime_with_tz

 def test_datetime_with_tz(self):
     n = datetime.datetime.now(dateutils.local_tz())
     s = dateutils.format_iso8601_datetime(n)
     b = dateutils.parse_iso8601_datetime(s)
     for f in self.dt_fields:
         self.assertTrue(getattr(n, f) == getattr(b, f), 'Field mismatch: %s' % f)
开发者ID:ehelms,项目名称:pulp,代码行数:6,代码来源:test_dateutils.py

示例12: test_utc_offset

 def test_utc_offset(self):
     n1 = datetime.datetime.now(dateutils.local_tz())
     u1 = dateutils.to_utc_datetime(n1)
     n2 = n1.replace(tzinfo=None)
     u2 = u1.replace(tzinfo=None)
     self.assertTrue(n2 - u2 == dateutils.local_utcoffset_delta())
开发者ID:ehelms,项目名称:pulp,代码行数:6,代码来源:test_dateutils.py

示例13: test_local_to_utz_tz_conversion

 def test_local_to_utz_tz_conversion(self):
     n1 = datetime.datetime.now(dateutils.local_tz())
     u = dateutils.to_utc_datetime(n1)
     n2 = dateutils.to_local_datetime(u)
     self.assertTrue(n1 == n2)
开发者ID:ehelms,项目名称:pulp,代码行数:5,代码来源:test_dateutils.py

示例14: test_tz_specified

 def test_tz_specified(self):
     dt = datetime.datetime.now(dateutils.local_tz())
     new_date = _ensure_tz_specified(dt)
     self.assertEquals(new_date.tzinfo, dateutils.utc_tz())
开发者ID:credativ,项目名称:pulp,代码行数:4,代码来源:test_common.py


注:本文中的pulp.common.dateutils.local_tz函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。