當前位置: 首頁>>代碼示例>>Python>>正文


Python time.min方法代碼示例

本文整理匯總了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) 
開發者ID:MycroftAI,項目名稱:selene-backend,代碼行數:18,代碼來源:api.py

示例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 
開發者ID:alphagov,項目名稱:notifications-api,代碼行數:25,代碼來源:fact_notification_status_dao.py

示例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 
開發者ID:alphagov,項目名稱:notifications-api,代碼行數:27,代碼來源:fact_billing_dao.py

示例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 
開發者ID:salopensource,項目名稱:sal,代碼行數:20,代碼來源:munkiinstalls.py

示例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) 
開發者ID:man-group,項目名稱:arctic,代碼行數:35,代碼來源:toplevel.py

示例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 
開發者ID:SverkerSbrg,項目名稱:openpyxl-templates,代碼行數:17,代碼來源:columns.py

示例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) 
開發者ID:andersroos,項目名稱:rankedftw,代碼行數:4,代碼來源:models.py

示例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()) 
開發者ID:andersroos,項目名稱:rankedftw,代碼行數:13,代碼來源:models.py

示例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 
開發者ID:alphagov,項目名稱:notifications-api,代碼行數:11,代碼來源:date_util.py

示例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] 
開發者ID:DMOJ,項目名稱:online-judge,代碼行數:10,代碼來源:contests.py

示例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 
開發者ID:DMOJ,項目名稱:online-judge,代碼行數:39,代碼來源:contests.py

示例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 
開發者ID:accelero-cloud,項目名稱:appkernel,代碼行數:7,代碼來源:generators.py

示例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) 
開發者ID:HealthRex,項目名稱:CDSS,代碼行數:8,代碼來源:TestSTARRDemographicsConversion.py

示例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 
開發者ID:BeanWei,項目名稱:Dailyfresh-B2C,代碼行數:17,代碼來源:fields.py

示例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) 
開發者ID:apache,項目名稱:allura,代碼行數:15,代碼來源:main.py


注:本文中的datetime.time.min方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。