本文整理汇总了Python中datetime.time.min方法的典型用法代码示例。如果您正苦于以下问题:Python time.min方法的具体用法?Python time.min怎么用?Python time.min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datetime.time
的用法示例。
在下文中一共展示了time.min方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_partition
# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import min [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: fetch_notification_status_for_day
# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import min [as 别名]
def fetch_notification_status_for_day(process_day, notification_type):
start_date = convert_bst_to_utc(datetime.combine(process_day, time.min))
end_date = convert_bst_to_utc(datetime.combine(process_day + timedelta(days=1), time.min))
current_app.logger.info("Fetch ft_notification_status for {} to {}".format(start_date, end_date))
all_data_for_process_day = []
services = Service.query.all()
# for each service query notifications or notification_history for the day, depending on their data retention
for service in services:
table = get_notification_table_to_use(service, notification_type, process_day, has_delete_task_run=False)
data_for_service_and_type = query_for_fact_status_data(
table=table,
start_date=start_date,
end_date=end_date,
notification_type=notification_type,
service_id=service.id
)
all_data_for_process_day += data_for_service_and_type
return all_data_for_process_day
示例3: fetch_billing_data_for_day
# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import min [as 别名]
def fetch_billing_data_for_day(process_day, service_id=None, check_permissions=False):
start_date = convert_bst_to_utc(datetime.combine(process_day, time.min))
end_date = convert_bst_to_utc(datetime.combine(process_day + timedelta(days=1), time.min))
current_app.logger.info("Populate ft_billing for {} to {}".format(start_date, end_date))
transit_data = []
if not service_id:
services = Service.query.all()
else:
services = [Service.query.get(service_id)]
for service in services:
for notification_type in (SMS_TYPE, EMAIL_TYPE, LETTER_TYPE):
if (not check_permissions) or service.has_permission(notification_type):
table = get_notification_table_to_use(service, notification_type, process_day,
has_delete_task_run=False)
results = _query_for_billing_data(
table=table,
notification_type=notification_type,
start_date=start_date,
end_date=end_date,
service=service
)
transit_data += results
return transit_data
示例4: get_context
# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import min [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
示例5: add
# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import min [as 别名]
def add(self, date_range, library_name):
"""
Adds the library with the given date range to the underlying collection of libraries used by this store.
The underlying libraries should not overlap as the date ranges are assumed to be CLOSED_CLOSED by this function
and the rest of the class.
Arguments:
date_range: A date range provided on the assumption that it is CLOSED_CLOSED. If for example the underlying
libraries were split by year, the start of the date range would be datetime.datetime(year, 1, 1) and the end
would be datetime.datetime(year, 12, 31, 23, 59, 59, 999000). The date range must fall on UTC day boundaries,
that is the start must be add midnight and the end must be 1 millisecond before midnight.
library_name: The name of the underlying library. This must be the name of a valid Arctic library
"""
# check that the library is valid
try:
self._arctic_lib.arctic[library_name]
except Exception as e:
logger.error("Could not load library")
raise e
assert date_range.start and date_range.end, "Date range should have start and end properties {}".format(date_range)
start = date_range.start.astimezone(mktz('UTC')) if date_range.start.tzinfo is not None else date_range.start.replace(tzinfo=mktz('UTC'))
end = date_range.end.astimezone(mktz('UTC')) if date_range.end.tzinfo is not None else date_range.end.replace(tzinfo=mktz('UTC'))
assert start.time() == time.min and end.time() == end_time_min, "Date range should fall on UTC day boundaries {}".format(date_range)
# check that the date range does not overlap
library_metadata = self._get_library_metadata(date_range)
if len(library_metadata) > 1 or (len(library_metadata) == 1 and library_metadata[0] != library_name):
raise OverlappingDataException("""There are libraries that overlap with the date range:
library: {}
overlapping libraries: {}""".format(library_name, [l.library for l in library_metadata]))
self._collection.update_one({'library_name': library_name},
{'$set': {'start': start, 'end': end}}, upsert=True)
示例6: to_excel
# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import min [as 别名]
def to_excel(self, value, row_type=None):
if type(value) == date:
value = datetime.combine(value, time.min)
if not isinstance(value, datetime):
raise UnableToParseDatetime(value=value)
delta = (value - datetime(year=1900, month=1, day=1, tzinfo=value.tzinfo))
value = delta.days + delta.seconds / self.SECONDS_PER_DAY + 2
# Excel incorrectly assumes 1900 to be a leap year.
if value < 61:
if value < 1:
raise UnableToParseDatetime(value=value)
value -= 1
return value
示例7: start_time
# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import min [as 别名]
def start_time(self, time_part=time.min):
return datetime.combine(self.start_date, time_part).replace(tzinfo=timezone.utc)
示例8: set_data_time
# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import min [as 别名]
def set_data_time(self, season, cpp):
""" Calculate and set data_times based off actual data and season. """
self.min_data_time, self.max_data_time = [from_unix(d) for d in cpp.min_max_data_time()]
if not self.min_data_time and not self.max_data_time:
self.min_data_time = self.max_data_time = self.data_time = season.start_time()
if season.is_open():
self.data_time = self.max_data_time
else:
self.data_time = min(self.max_data_time, season.end_time())
示例9: get_financial_year_for_datetime
# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import min [as 别名]
def get_financial_year_for_datetime(start_date):
if type(start_date) == date:
start_date = datetime.combine(start_date, time.min)
year = int(start_date.strftime('%Y'))
if start_date < get_april_fools(year):
return year - 1
else:
return year
示例10: get_table
# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import min [as 别名]
def get_table(self):
calendar = Calendar(self.firstweekday).monthdatescalendar(self.year, self.month)
starts, ends, oneday = self.get_contest_data(make_aware(datetime.combine(calendar[0][0], time.min)),
make_aware(datetime.combine(calendar[-1][-1], time.min)))
return [[ContestDay(
date=date, weekday=self.weekday_classes[weekday], is_pad=date.month != self.month,
is_today=date == self.today, starts=starts[date], ends=ends[date], oneday=oneday[date],
) for weekday, date in enumerate(week)] for week in calendar]
示例11: get_context_data
# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import min [as 别名]
def get_context_data(self, **kwargs):
context = super(ContestCalendar, self).get_context_data(**kwargs)
try:
month = date(self.year, self.month, 1)
except ValueError:
raise Http404()
else:
context['title'] = _('Contests in %(month)s') % {'month': date_filter(month, _("F Y"))}
dates = Contest.objects.aggregate(min=Min('start_time'), max=Max('end_time'))
min_month = (self.today.year, self.today.month)
if dates['min'] is not None:
min_month = dates['min'].year, dates['min'].month
max_month = (self.today.year, self.today.month)
if dates['max'] is not None:
max_month = max((dates['max'].year, dates['max'].month), (self.today.year, self.today.month))
month = (self.year, self.month)
if month < min_month or month > max_month:
# 404 is valid because it merely declares the lack of existence, without any reason
raise Http404()
context['now'] = timezone.now()
context['calendar'] = self.get_table()
context['curr_month'] = date(self.year, self.month, 1)
if month > min_month:
context['prev_month'] = date(self.year - (self.month == 1), 12 if self.month == 1 else self.month - 1, 1)
else:
context['prev_month'] = None
if month < max_month:
context['next_month'] = date(self.year + (self.month == 12), 1 if self.month == 12 else self.month + 1, 1)
else:
context['next_month'] = None
return context
示例12: to_wireformat
# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import min [as 别名]
def to_wireformat(self, instance_value: date):
if isinstance(instance_value, date):
return datetime.combine(instance_value, dtime.min)
else:
return instance_value
示例13: death_date_tuple_from
# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import min [as 别名]
def death_date_tuple_from(birth_list, row):
death_list = list(birth_list)
death_list[5] = "Death"
death_list[6] = "Death Date"
death_list[7] = datetime.combine(row[2], time.min).replace(tzinfo=pytz.UTC)
return tuple(death_list)
示例14: compress
# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import min [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
示例15: index
# 需要导入模块: from datetime import time [as 别名]
# 或者: from datetime.time import min [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)