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


Python time.microsecond方法代码示例

本文整理汇总了Python中time.microsecond方法的典型用法代码示例。如果您正苦于以下问题:Python time.microsecond方法的具体用法?Python time.microsecond怎么用?Python time.microsecond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在time的用法示例。


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

示例1: combine

# 需要导入模块: import time [as 别名]
# 或者: from time import microsecond [as 别名]
def combine(self, date, time):
        return datetime(date.year, date.month, date.day, time.hour, time.minute, time.microsecond, time.tzinfo) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:4,代码来源:datetime_safe.py

示例2: new_datetime

# 需要导入模块: import time [as 别名]
# 或者: from time import microsecond [as 别名]
def new_datetime(d):
    """
    Generate a safe datetime from a datetime.date or datetime.datetime object.
    """
    kw = [d.year, d.month, d.day]
    if isinstance(d, real_datetime):
        kw.extend([d.hour, d.minute, d.second, d.microsecond, d.tzinfo])
    return datetime(*kw)

# This library does not support strftime's "%s" or "%y" format strings.
# Allowed if there's an even number of "%"s because they are escaped. 
开发者ID:blackye,项目名称:luscan-devel,代码行数:13,代码来源:datetime_safe.py

示例3: _bump_up_time_by_microsecond

# 需要导入模块: import time [as 别名]
# 或者: from time import microsecond [as 别名]
def _bump_up_time_by_microsecond(time):
    """
    Helper function bumping up the given datetime.time by a microsecond,
    cycling around silently to 00:00:00.0 in case of an overflow.

    @param time: Time object.
    @type time: B{datetime}.I{time}
    @return: Time object.
    @rtype: B{datetime}.I{time}

    """
    dt = datetime.datetime(2000, 1, 1, time.hour, time.minute,
        time.second, time.microsecond)
    dt += datetime.timedelta(microseconds=1)
    return dt.time() 
开发者ID:suds-community,项目名称:suds,代码行数:17,代码来源:date.py

示例4: _time_from_match

# 需要导入模块: import time [as 别名]
# 或者: from time import microsecond [as 别名]
def _time_from_match(match_object):
    """
    Create a time object from a regular expression match.

    Returns the time object and information whether the resulting time should
    be bumped up by one microsecond due to microsecond rounding.

    Subsecond information is rounded to microseconds due to a restriction in
    the python datetime.datetime/time implementation.

    The regular expression match is expected to be from _RE_DATETIME or
    _RE_TIME.

    @param match_object: The regular expression match.
    @type match_object: B{re}.I{MatchObject}
    @return: Time object + rounding flag.
    @rtype: tuple of B{datetime}.I{time} and bool

    """
    hour = int(match_object.group('hour'))
    minute = int(match_object.group('minute'))
    second = int(match_object.group('second'))
    subsecond = match_object.group('subsecond')

    round_up = False
    microsecond = 0
    if subsecond:
        round_up = len(subsecond) > 6 and int(subsecond[6]) >= 5
        subsecond = subsecond[:6]
        microsecond = int(subsecond + "0" * (6 - len(subsecond)))
    return datetime.time(hour, minute, second, microsecond), round_up 
开发者ID:suds-community,项目名称:suds,代码行数:33,代码来源:date.py

示例5: today

# 需要导入模块: import time [as 别名]
# 或者: from time import microsecond [as 别名]
def today(timezone=None, format=None):
    """Returns today's date at midnight as a DADateTime object."""
    ensure_definition(timezone, format)
    if timezone is None:
        timezone = get_default_timezone()
    val = pytz.utc.localize(datetime.datetime.utcnow()).astimezone(pytz.timezone(timezone))
    if format is not None:
        return dd(val.replace(hour=0, minute=0, second=0, microsecond=0)).format_date(format)
    else:
        return dd(val.replace(hour=0, minute=0, second=0, microsecond=0)) 
开发者ID:jhpyle,项目名称:docassemble,代码行数:12,代码来源:util.py

示例6: replace_time

# 需要导入模块: import time [as 别名]
# 或者: from time import microsecond [as 别名]
def replace_time(self, time):
        return self.replace(hour=time.hour, minute=time.minute, second=time.second, microsecond=time.microsecond) 
开发者ID:jhpyle,项目名称:docassemble,代码行数:4,代码来源:util.py

示例7: dd

# 需要导入模块: import time [as 别名]
# 或者: from time import microsecond [as 别名]
def dd(obj):
    if isinstance(obj, DADateTime):
        return obj
    return DADateTime(obj.year, month=obj.month, day=obj.day, hour=obj.hour, minute=obj.minute, second=obj.second, microsecond=obj.microsecond, tzinfo=obj.tzinfo) 
开发者ID:jhpyle,项目名称:docassemble,代码行数:6,代码来源:util.py

示例8: dt

# 需要导入模块: import time [as 别名]
# 或者: from time import microsecond [as 别名]
def dt(obj):
    return datetime.datetime(obj.year, obj.month, obj.day, obj.hour, obj.minute, obj.second, obj.microsecond, obj.tzinfo) 
开发者ID:jhpyle,项目名称:docassemble,代码行数:4,代码来源:util.py


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