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


Python rfc822.mktime_tz方法代码示例

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


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

示例1: parse

# 需要导入模块: import rfc822 [as 别名]
# 或者: from rfc822 import mktime_tz [as 别名]
def parse(self, *args, **kwargs):
        """ return the time value (in seconds since 1970) """
        value = self.__call__(*args, **kwargs)
        if value:
            try:
                return mktime_tz(parsedate_tz(value))
            except TypeError:
                raise HTTPBadRequest((
                    "Received an ill-formed timestamp for %s: %s\r\n") %
                    (self.name, value))

#
# Following are specific HTTP headers. Since these classes are mostly
# singletons, there is no point in keeping the class around once it has
# been instantiated, so we use the same name.
# 
开发者ID:linuxscout,项目名称:mishkal,代码行数:18,代码来源:httpheaders.py

示例2: _parse_date_rfc822

# 需要导入模块: import rfc822 [as 别名]
# 或者: from rfc822 import mktime_tz [as 别名]
def _parse_date_rfc822(dateString):
    '''Parse an RFC822, RFC1123, RFC2822, or asctime-style date'''
    data = dateString.split()
    if data[0][-1] in (',', '.') or data[0].lower() in rfc822._daynames:
        del data[0]
    if len(data) == 4:
        s = data[3]
        i = s.find('+')
        if i > 0:
            data[3:] = [s[:i], s[i+1:]]
        else:
            data.append('')
        dateString = " ".join(data)
    if len(data) < 5:
        dateString += ' 00:00:00 GMT'
    tm = rfc822.parsedate_tz(dateString)
    if tm:
        return time.gmtime(rfc822.mktime_tz(tm))
# rfc822.py defines several time zones, but we define some extra ones.
# 'ET' is equivalent to 'EST', etc. 
开发者ID:MyRobotLab,项目名称:pyrobotlab,代码行数:22,代码来源:feedparser.py

示例3: _parse_date_perforce

# 需要导入模块: import rfc822 [as 别名]
# 或者: from rfc822 import mktime_tz [as 别名]
def _parse_date_perforce(aDateString):
    """parse a date in yyyy/mm/dd hh:mm:ss TTT format"""
    # Fri, 2006/09/15 08:19:53 EDT
    _my_date_pattern = re.compile( \
        r'(\w{,3}), (\d{,4})/(\d{,2})/(\d{2}) (\d{,2}):(\d{2}):(\d{2}) (\w{,3})')

    m = _my_date_pattern.search(aDateString)
    if m is None:
        return None
    dow, year, month, day, hour, minute, second, tz = m.groups()
    months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    dateString = "%s, %s %s %s %s:%s:%s %s" % (dow, day, months[int(month) - 1], year, hour, minute, second, tz)
    tm = rfc822.parsedate_tz(dateString)
    if tm:
        return time.gmtime(rfc822.mktime_tz(tm)) 
开发者ID:liantian-cn,项目名称:RSSNewsGAE,代码行数:17,代码来源:feedparser.py

示例4: rfc822_timestamp

# 需要导入模块: import rfc822 [as 别名]
# 或者: from rfc822 import mktime_tz [as 别名]
def rfc822_timestamp(time_string):
    return datetime.fromtimestamp(rfc822.mktime_tz(rfc822.parsedate_tz(time_string))) 
开发者ID:XiaoMi,项目名称:galaxy-fds-sdk-python,代码行数:4,代码来源:utils.py

示例5: get_contents_to_filename

# 需要导入模块: import rfc822 [as 别名]
# 或者: from rfc822 import mktime_tz [as 别名]
def get_contents_to_filename(self, filename, headers=None,
                                 cb=None, num_cb=10,
                                 torrent=False,
                                 version_id=None,
                                 res_download_handler=None,
                                 response_headers=None):
        """
        Retrieve an object from S3 using the name of the Key object as the
        key in S3.  Store contents of the object to a file named by 'filename'.
        See get_contents_to_file method for details about the
        parameters.

        :type filename: string
        :param filename: The filename of where to put the file contents

        :type headers: dict
        :param headers: Any additional headers to send in the request

        :type cb: function
        :param cb: a callback function that will be called to report
                   progress on the upload.  The callback should accept
                   two integer parameters, the first representing the
                   number of bytes that have been successfully
                   transmitted to S3 and the second representing the
                   size of the to be transmitted object.

        :type cb: int
        :param num_cb: (optional) If a callback is specified with
                       the cb parameter this parameter determines the
                       granularity of the callback by defining
                       the maximum number of times the callback will
                       be called during the file transfer.

        :type torrent: bool
        :param torrent: If True, returns the contents of a torrent file
                        as a string.

        :type res_upload_handler: ResumableDownloadHandler
        :param res_download_handler: If provided, this handler will
                                     perform the download.

        :type response_headers: dict
        :param response_headers: A dictionary containing HTTP headers/values
                                 that will override any headers associated with
                                 the stored object in the response.
                                 See http://goo.gl/EWOPb for details.
        """
        fp = open(filename, 'wb')
        self.get_contents_to_file(fp, headers, cb, num_cb, torrent=torrent,
                                  version_id=version_id,
                                  res_download_handler=res_download_handler,
                                  response_headers=response_headers)
        fp.close()
        # if last_modified date was sent from s3, try to set file's timestamp
        if self.last_modified != None:
            try:
                modified_tuple = rfc822.parsedate_tz(self.last_modified)
                modified_stamp = int(rfc822.mktime_tz(modified_tuple))
                os.utime(fp.name, (modified_stamp, modified_stamp))
            except Exception: pass 
开发者ID:canvasnetworks,项目名称:canvas,代码行数:62,代码来源:key.py


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