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


Python time.max方法代码示例

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


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

示例1: create_partition

# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import max [as 别名]
def create_partition(self, partition_date: date):
        """Create a daily partition for the metric.api_history table."""
        start_ts = datetime.combine(partition_date, time.min)
        end_ts = datetime.combine(partition_date, time.max)
        db_request = self._build_db_request(
            sql_file_name='create_api_metric_partition.sql',
            args=dict(start_ts=str(start_ts), end_ts=str(end_ts)),
            sql_vars=dict(partition=partition_date.strftime('%Y%m%d'))
        )
        self.cursor.execute(db_request)

        db_request = self._build_db_request(
            sql_file_name='create_api_metric_partition_index.sql',
            sql_vars=dict(partition=partition_date.strftime('%Y%m%d'))
        )
        self.cursor.execute(db_request) 
开发者ID:MycroftAI,项目名称:selene-backend,代码行数:18,代码来源:api.py

示例2: get_context

# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import max [as 别名]
def get_context(self, queryset, **kwargs):
        context = self.super_get_context(queryset, **kwargs)

        # Set up 14 days back of time ranges as a generator.
        now = timezone.now()
        days = (now - timedelta(days=d) for d in range(0, 15))
        time_ranges = ((
            timezone.make_aware(datetime.combine(d, time.min)),
            timezone.make_aware(datetime.combine(d, time.max))) for d in days)

        # For each day, get a count of installs, pending, and errors,
        # and the date, as a list of dicts.
        context['data'] = []
        for time_range in time_ranges:
            day_status = {key: self._filter(queryset, key, time_range) for key in STATUSES}
            day_status['date'] = time_range[0].strftime("%Y-%m-%d")
            context['data'].append(day_status)
        return context 
开发者ID:salopensource,项目名称:sal,代码行数:20,代码来源:munkiinstalls.py

示例3: end_time

# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import max [as 别名]
def end_time(self, time_part=time.max):
        return datetime.combine(self.end_date, time_part).replace(tzinfo=timezone.utc) 
开发者ID:andersroos,项目名称:rankedftw,代码行数:4,代码来源:models.py

示例4: display_primary_module

# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import max [as 别名]
def display_primary_module(self):
        if self.site_details and self.site_details.get('primaryModule'):
            v = self.site_details.get('primaryModule')
            a = v.get('modelName')
            if v.get('manufacturerName'):
                a += ' manufactured by ' + v.get('manufacturerName')
            if v.get('maximumPower'):
                a += ', max power ' + str(v.get('maximumPower'))
            if v.get('temperatureCoef'):
                a += ', temperature coefficient ' + str(v.get('temperatureCoef'))
            return a

        return None 
开发者ID:opentaps,项目名称:opentaps_seas,代码行数:15,代码来源:models.py

示例5: compress

# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import max [as 别名]
def compress(self, data_list):
        if data_list:
            start_date, stop_date = data_list
            if start_date:
                start_date = handle_timezone(
                    datetime.combine(start_date, time.min),
                    False
                )
            if stop_date:
                stop_date = handle_timezone(
                    datetime.combine(stop_date, time.max),
                    False
                )
            return slice(start_date, stop_date)
        return None 
开发者ID:BeanWei,项目名称:Dailyfresh-B2C,代码行数:17,代码来源:fields.py

示例6: index

# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import max [as 别名]
def index(self, **kw):
        q = dict(
            timestamp={
                '$gte': datetime.combine(self.day, time.min),
                '$lte': datetime.combine(self.day, time.max)})
        messages = CM.ChatMessage.query.find(q).sort('timestamp').all()
        prev = c.app.url + (self.day - timedelta(days=1)).strftime('%Y/%m/%d/')
        next = c.app.url + (self.day + timedelta(days=1)).strftime('%Y/%m/%d/')
        return dict(
            day=self.day,
            messages=messages,
            prev=prev,
            next=next) 
开发者ID:apache,项目名称:allura,代码行数:15,代码来源:main.py

示例7: to_native

# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import max [as 别名]
def to_native(self, value, context=None):
        if isinstance(value, datetime):
            return value
        return datetime.combine(parse_date(value), dt_time.max) 
开发者ID:predicthq,项目名称:sdk-py,代码行数:6,代码来源:schemas.py

示例8: _load

# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import max [as 别名]
def _load(probe, starttime, endtime, instrument, product_id,
          try_download):
    dirs = []
    fnames = []
    download_info = []
    for day in util._daysplitinterval(starttime, endtime):
        date = day[0]
        year = str(date.year)
        month = str(date.month).zfill(2)
        day = str(date.day).zfill(2)

        dirs.append(year)
        local_fname = 'C' + probe + '_' + product_id + '__' +\
            year + month + day
        fnames.append(local_fname)
        thisstart = datetime.combine(date, time.min)
        thisend = datetime.combine(date, time.max)
        download_info.append((thisstart, thisend))

    extension = '.cdf'
    local_base_dir = cluster_dir / ('c' + probe) / instrument
    remote_base_url = csa_url

    def download_func(remote_base_url, local_base_dir,
                      directory, fname, remote_fname, extension,
                      download_info):
        starttime, endtime = download_info
        _download(probe, starttime, endtime, instrument, product_id)

    def processing_func(file):
        for non_empty_var in list(file.cdf_info().keys()):
            if 'variable' in non_empty_var.lower():
                if len(file.cdf_info()[non_empty_var]) > 0:
                    var_list = non_empty_var
                    break

        for key in file.cdf_info()[var_list]:
            if 'CDF_EPOCH' in file.varget(key, expand=True).values():
                index_key = key
                break
        return util.cdf2df(file, index_key)

    return util.process(dirs, fnames, extension, local_base_dir,
                        remote_base_url, download_func, processing_func,
                        starttime, endtime, try_download=try_download,
                        units=None,
                        download_info=download_info) 
开发者ID:heliopython,项目名称:heliopy,代码行数:49,代码来源:cluster.py

示例9: stats_data

# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import max [as 别名]
def stats_data(self, begin=None, end=None, forum=None, **kw):
        end = end or date.today()
        begin = begin or end - timedelta(days=60)

        discussion_id_q = {
            '$in': [d._id for d in c.app.forums
                    if d.shortname == forum or not forum]
        }
        # must be ordered dict, so that sorting by this works properly
        grouping = OrderedDict()
        grouping['year'] = {'$year': '$timestamp'}
        grouping['month'] = {'$month': '$timestamp'}
        grouping['day'] = {'$dayOfMonth': '$timestamp'}
        mongo_data = model.ForumPost.query.aggregate([
            {'$match': {
                'discussion_id': discussion_id_q,
                'status': 'ok',
                'timestamp': {
                    # convert date to datetime to make pymongo happy
                    '$gte': datetime.combine(begin, time.min),
                    '$lte': datetime.combine(end, time.max),
                },
                'deleted': False,
            }},
            {'$group': {
                '_id': grouping,
                'posts': {'$sum': 1},
            }},
            {'$sort': {
                '_id': pymongo.ASCENDING,
            }},
        ], cursor={})

        def reformat_data(mongo_data):
            def item(day, val):
                return [
                    calendar.timegm(day.timetuple()) * 1000,
                    val
                ]

            next_expected_date = begin
            for d in mongo_data:
                this_date = datetime(
                    d['_id']['year'], d['_id']['month'], d['_id']['day'])
                for day in h.daterange(next_expected_date, this_date):
                    yield item(day, 0)
                yield item(this_date, d['posts'])
                next_expected_date = this_date + timedelta(days=1)
            for day in h.daterange(next_expected_date, end + timedelta(days=1)):
                yield item(day, 0)

        return dict(
            begin=begin,
            end=end,
            data=list(reformat_data(mongo_data)),
        ) 
开发者ID:apache,项目名称:allura,代码行数:58,代码来源:root.py


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