本文整理汇总了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)
示例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
示例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)
示例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
示例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
示例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)
示例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)
示例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)
示例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)),
)