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


Python DateTime.add_century方法代码示例

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


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

示例1: ParseDate

# 需要导入模块: import DateTime [as 别名]
# 或者: from DateTime import add_century [as 别名]
def ParseDate(arpastring,parse_arpadate=arpadateRE.match):

    """ ParseDate(arpastring)

        Returns a DateTime instance reflecting the given ARPA
        date. Only the date part is parsed, any time part will be
        ignored. The instance's time is set to 0:00:00.

    """
    s = arpastring.strip()
    date = parse_arpadate(s)
    if not date:
        raise ValueError,'wrong format'
    litday,day,litmonth,month,year = date.groups()
    if len(year) == 2:
        year = DateTime.add_century(int(year))
    else:
        year = int(year)
    if litmonth:
        litmonth = litmonth.lower()
        try:
            month = litmonthtable[litmonth]
        except KeyError:
            raise ValueError,'wrong month format'
    else:
        month = int(month)
    day = int(day)
    # litday and timezone are ignored
    return DateTime.DateTime(year,month,day)
开发者ID:rfleschenberg,项目名称:egenix-mx-base-python-2x3,代码行数:31,代码来源:ARPA.py

示例2: ParseDateTime

# 需要导入模块: import DateTime [as 别名]
# 或者: from DateTime import add_century [as 别名]
def ParseDateTime(arpastring,parse_arpadatetime=arpadatetimeRE.match):

    """ ParseDateTime(arpastring)

        Returns a DateTime instance reflecting the given ARPA date
        assuming it is local time (timezones are silently ignored).
        
    """
    s = arpastring.strip()
    date = parse_arpadatetime(s)
    if not date:
        raise ValueError,'wrong format or unknown time zone'
    litday,day,litmonth,month,year,hour,minute,second,zone = date.groups()
    if len(year) == 2:
        year = DateTime.add_century(int(year))
    else:
        year = int(year)
    if litmonth:
        litmonth = litmonth.lower()
        try:
            month = litmonthtable[litmonth]
        except KeyError:
            raise ValueError,'wrong month format'
    else:
        month = int(month)
    day = int(day)
    hour = int(hour)
    minute = int(minute)
    if second is None:
        second = 0.0
    else:
        second = float(second)
    # litday and timezone are ignored
    return DateTime.DateTime(year,month,day,hour,minute,second)
开发者ID:rfleschenberg,项目名称:egenix-mx-base-python-2x3,代码行数:36,代码来源:ARPA.py

示例3: ParseDateTimeGMT

# 需要导入模块: import DateTime [as 别名]
# 或者: from DateTime import add_century [as 别名]
def ParseDateTimeGMT(arpastring,parse_arpadatetime=arpadatetimeRE.match,

                     strip=string.strip,atoi=string.atoi,atof=string.atof,
                     lower=string.lower):

    """ParseDateTimeGMT(arpastring)

       Returns a DateTime instance reflecting the given ARPA date converting
       it to UTC (timezones are honored).
    """
    s = strip(arpastring)
    date = parse_arpadatetime(s)
    if not date:
        raise ValueError,'wrong format or unknown time zone'
    litday,day,litmonth,month,year,hour,minute,second,zone = date.groups()
    if len(year) == 2:
        year = DateTime.add_century(atoi(year))
    else:
        year = atoi(year)
    if litmonth:
        litmonth = lower(litmonth)
        try:
            month = litmonthtable[litmonth]
        except KeyError:
            raise ValueError,'wrong month format'
    else:
        month = atoi(month)
    day = atoi(day)
    hour = atoi(hour)
    minute = atoi(minute)
    if second is None:
        second = 0.0
    else:
        second = atof(second)
    offset = Timezone.utc_offset(zone)
    # litday is ignored
    return DateTime.DateTime(year,month,day,hour,minute,second) - offset
开发者ID:tobiasvl,项目名称:cerebrum-devutils,代码行数:39,代码来源:ARPA.py


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