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


Python date.day方法代碼示例

本文整理匯總了Python中datetime.date.day方法的典型用法代碼示例。如果您正苦於以下問題:Python date.day方法的具體用法?Python date.day怎麽用?Python date.day使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在datetime.date的用法示例。


在下文中一共展示了date.day方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: format_week

# 需要導入模塊: from datetime import date [as 別名]
# 或者: from datetime.date import day [as 別名]
def format_week(self, char, num):
        if char.islower(): # week of year
            day_of_year = self.get_day_of_year()
            week = self.get_week_number(day_of_year)
            if week == 0:
                date = self.value - timedelta(days=day_of_year)
                week = self.get_week_number(self.get_day_of_year(date),
                                            date.weekday())
            return self.format(week, num)
        else: # week of month
            week = self.get_week_number(self.value.day)
            if week == 0:
                date = self.value - timedelta(days=self.value.day)
                week = self.get_week_number(date.day, date.weekday())
                pass
            return '%d' % week 
開發者ID:Schibum,項目名稱:sndlatr,代碼行數:18,代碼來源:dates.py

示例2: apply

# 需要導入模塊: from datetime import date [as 別名]
# 或者: from datetime.date import day [as 別名]
def apply(self, other):
        other = datetime(other.year, other.month, other.day)

        n = self.n

        wkday, days_in_month = tslib.monthrange(other.year, other.month)
        lastBDay = days_in_month - max(((wkday + days_in_month - 1)
                                        % 7) - 4, 0)

        if n > 0 and not other.day >= lastBDay:
            n = n - 1
        elif n <= 0 and other.day > lastBDay:
            n = n + 1
        other = as_datetime(other) + relativedelta(months=n, day=31)

        if other.weekday() > 4:
            other = other - BDay()
        return other 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:20,代碼來源:offsets.py

示例3: __init__

# 需要導入模塊: from datetime import date [as 別名]
# 或者: from datetime.date import day [as 別名]
def __init__(self, n=1, **kwds):
        self.n = n
        self.weekday = kwds['weekday']
        self.week = kwds['week']

        if self.n == 0:
            raise ValueError('N cannot be 0')

        if self.weekday < 0 or self.weekday > 6:
            raise ValueError('Day must be 0<=day<=6, got %d' %
                             self.weekday)
        if self.week < 0 or self.week > 3:
            raise ValueError('Week must be 0<=day<=3, got %d' %
                             self.week)

        self.kwds = kwds 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:18,代碼來源:offsets.py

示例4: get_day_names

# 需要導入模塊: from datetime import date [as 別名]
# 或者: from datetime.date import day [as 別名]
def get_day_names(width='wide', context='format', locale=LC_TIME):
    """Return the day names used by the locale for the specified format.

    >>> get_day_names('wide', locale='en_US')[1]
    u'Tuesday'
    >>> get_day_names('short', locale='en_US')[1]
    u'Tu'
    >>> get_day_names('abbreviated', locale='es')[1]
    u'mar.'
    >>> get_day_names('narrow', context='stand-alone', locale='de_DE')[1]
    u'D'

    :param width: the width to use, one of "wide", "abbreviated", "short" or "narrow"
    :param context: the context, either "format" or "stand-alone"
    :param locale: the `Locale` object, or a locale string
    """
    return Locale.parse(locale).days[context][width] 
開發者ID:luckystarufo,項目名稱:pySINDy,代碼行數:19,代碼來源:dates.py

示例5: dga

# 需要導入模塊: from datetime import date [as 別名]
# 或者: from datetime.date import day [as 別名]
def dga(date, seed, nr):
  tlds = ['.in', '.me', '.cc', '.su', '.tw', '.net', '.com', '.pw', '.org']
  tld_index = date.day
  day = date.day
  month = date.month
  year = date.year
  uint_mask = 0xFFFFFFFF
  for d in range(nr):
    domain = ''
    for i in range(14):
      day = (day >> 15) ^ 16 * (day & 0x1FFF ^ 4 * (seed ^ day))
      day &= uint_mask
      year_times7 = 7 * year & uint_mask
      year = (((year & 0xFFFFFFF0) << 17) & uint_mask) ^ ((year ^ year_times7) >> 11)
      month_times4 = 4 * month & uint_mask
      month = (14 * (month & 0xFFFFFFFE) & uint_mask) ^ ((month ^ month_times4) >> 8)
      seed_times8 = 8 * seed & uint_mask
      seed = (seed >> 6) ^ ((day + seed_times8 << 8) & uint_mask) & 0x3FFFF00
      x = ((day ^ month ^ year) % 25) + 97
      domain += chr(x)
    print(domain + tlds[tld_index % 8])
    tld_index += 1 
開發者ID:pchaigno,項目名稱:dga-collection,代碼行數:24,代碼來源:ranbyus.py

示例6: from_dict

# 需要導入模塊: from datetime import date [as 別名]
# 或者: from datetime.date import day [as 別名]
def from_dict(cls, data):
        """Create datetime from a dictionary.

        Args:
            data: A python dictionary in the following format

        .. code-block:: python

                {
                'month': 1  #A value for month between 1-12. (Default: 1)
                'day': 1  # A value for day between 1-31. (Default: 1)
                'hour': 0  # A value for hour between 0-23. (Default: 0)
                'minute': 0  # A value for month between 0-59. (Default: 0)
                }
        """
        month = data['month'] if 'month' in data else 1
        day = data['day'] if 'day' in data else 1
        hour = data['hour'] if 'hour' in data else 0
        minute = data['minute'] if 'minute' in data else 0
        leap_year = data['leap_year'] if 'leap_year' in data else False
        return cls(month, day, hour, minute, leap_year) 
開發者ID:ladybug-tools,項目名稱:ladybug,代碼行數:23,代碼來源:dt.py

示例7: from_date_time_string

# 需要導入模塊: from datetime import date [as 別名]
# 或者: from datetime.date import day [as 別名]
def from_date_time_string(cls, datetime_string, leap_year=False):
        """Create Ladybug DateTime from a DateTime string.

        Args:
            datetime_string: A text string representing a DateTime
                (ie. "21 Jun 12:00")
            leap_year: Boolean to note whether the Date Time is a part of a
                leap year. Default: False.

        Usage:

        .. code-block:: python

            dt = DateTime.from_date_time_string("31 Dec 12:00")
        """
        try:
            dt = datetime.strptime(datetime_string, '%d %b %H:%M')
        except AttributeError:  # older Python version before strptime
            vals = datetime_string.split(' ')
            tim = vals[-1].split(':')
            dt = datetime(2016, MONTHNAMES.index(vals[1]) + 1, int(vals[0]),
                          int(tim[0]), int(tim[1]))
        return cls(dt.month, dt.day, dt.hour, dt.minute, leap_year) 
開發者ID:ladybug-tools,項目名稱:ladybug,代碼行數:25,代碼來源:dt.py

示例8: dateToString

# 需要導入模塊: from datetime import date [as 別名]
# 或者: from datetime.date import day [as 別名]
def dateToString(date):
    if share.config.datetypes[share.config.datetype] == "jalali":
        jd = DateEntry.cal.gregorian_to_jd(date.year, date.month, date.day)
        (year, month, day) = DateEntry.cal.jd_to_jalali(jd)
    else:
        (year, month, day) = (date.year, date.month, date.day)

    datelist = ["", "", ""]
    datelist[share.config.datefields["year"]] = year
    datelist[share.config.datefields["month"]] = month
    datelist[share.config.datefields["day"]] = day

    delim = share.config.datedelims[share.config.datedelim]
    datestring = str(datelist[0]) + delim + \
        str(datelist[1]) + delim + str(datelist[2])
    datestring = LN(datestring, False)
    return datestring 
開發者ID:Jooyeshgar,項目名稱:amir,代碼行數:19,代碼來源:dateentry.py

示例9: stringToDate

# 需要導入模塊: from datetime import date [as 別名]
# 或者: from datetime.date import day [as 別名]
def stringToDate(dateString):
    dateString = convertToLatin(dateString)
    delim = share.config.datedelims[share.config.datedelim]
    dateList = dateString.split(delim)
    if len(dateList) == 3:
        if dateList[0] != '' and dateList[1] != '' and dateList[2] != '':
            dy = int(dateList[share.config.datefields["year"]])
            dm = int(dateList[share.config.datefields["month"]])
            dd = int(dateList[share.config.datefields["day"]])
            d = (dy, dm, dd)
            de = DateEntry(d)
            try:
                dateObj = de.getDateObject()
            except:
                return
            return dateObj
## @}

## \defgroup Widgets
## @{ 
開發者ID:Jooyeshgar,項目名稱:amir,代碼行數:22,代碼來源:dateentry.py

示例10: showDate

# 需要導入模塊: from datetime import date [as 別名]
# 或者: from datetime.date import day [as 別名]
def showDate(self, year, month, day):
        datelist = ["", "", ""]
        datelist[share.config.datefields["year"]] = year
        datelist[share.config.datefields["month"]] = month
        datelist[share.config.datefields["day"]] = day

        delim = share.config.datedelims[share.config.datedelim]
        datestring = str(datelist[0]) + delim + \
            str(datelist[1]) + delim + str(datelist[2])
        datestring = LN(datestring, False)
        self.set_text(datestring)
        self.year = year
        self.month = month
        self.day = day

    # Assuming that date objects show gregorian date. 
開發者ID:Jooyeshgar,項目名稱:amir,代碼行數:18,代碼來源:dateentry.py

示例11: _next_opening_time

# 需要導入模塊: from datetime import date [as 別名]
# 或者: from datetime.date import day [as 別名]
def _next_opening_time(self, other):
        """
        If n is positive, return tomorrow's business day opening time.
        Otherwise yesterday's business day's opening time.

        Opening time always locates on BusinessDay.
        Otherwise, closing time may not if business hour extends over midnight.
        """
        if not self.next_bday.onOffset(other):
            other = other + self.next_bday
        else:
            if self.n >= 0 and self.start < other.time():
                other = other + self.next_bday
            elif self.n < 0 and other.time() < self.start:
                other = other + self.next_bday
        return datetime(other.year, other.month, other.day,
                        self.start.hour, self.start.minute) 
開發者ID:nccgroup,項目名稱:Splunking-Crime,代碼行數:19,代碼來源:offsets.py

示例12: get_period_names

# 需要導入模塊: from datetime import date [as 別名]
# 或者: from datetime.date import day [as 別名]
def get_period_names(locale=LC_TIME):
    """Return the names for day periods (AM/PM) used by the locale.

    >>> get_period_names(locale='en_US')['am']
    u'AM'

    :param locale: the `Locale` object, or a locale string
    """
    return Locale.parse(locale).periods 
開發者ID:Schibum,項目名稱:sndlatr,代碼行數:11,代碼來源:dates.py

示例13: get_day_names

# 需要導入模塊: from datetime import date [as 別名]
# 或者: from datetime.date import day [as 別名]
def get_day_names(width='wide', context='format', locale=LC_TIME):
    """Return the day names used by the locale for the specified format.

    >>> get_day_names('wide', locale='en_US')[1]
    u'Tuesday'
    >>> get_day_names('abbreviated', locale='es')[1]
    u'mar'
    >>> get_day_names('narrow', context='stand-alone', locale='de_DE')[1]
    u'D'

    :param width: the width to use, one of "wide", "abbreviated", or "narrow"
    :param context: the context, either "format" or "stand-alone"
    :param locale: the `Locale` object, or a locale string
    """
    return Locale.parse(locale).days[context][width] 
開發者ID:Schibum,項目名稱:sndlatr,代碼行數:17,代碼來源:dates.py

示例14: parse_date

# 需要導入模塊: from datetime import date [as 別名]
# 或者: from datetime.date import day [as 別名]
def parse_date(string, locale=LC_TIME):
    """Parse a date from a string.

    This function uses the date format for the locale as a hint to determine
    the order in which the date fields appear in the string.

    >>> parse_date('4/1/04', locale='en_US')
    datetime.date(2004, 4, 1)
    >>> parse_date('01.04.2004', locale='de_DE')
    datetime.date(2004, 4, 1)

    :param string: the string containing the date
    :param locale: a `Locale` object or a locale identifier
    """
    # TODO: try ISO format first?
    format = get_date_format(locale=locale).pattern.lower()
    year_idx = format.index('y')
    month_idx = format.index('m')
    if month_idx < 0:
        month_idx = format.index('l')
    day_idx = format.index('d')

    indexes = [(year_idx, 'Y'), (month_idx, 'M'), (day_idx, 'D')]
    indexes.sort()
    indexes = dict([(item[1], idx) for idx, item in enumerate(indexes)])

    # FIXME: this currently only supports numbers, but should also support month
    #        names, both in the requested locale, and english

    numbers = re.findall('(\d+)', string)
    year = numbers[indexes['Y']]
    if len(year) == 2:
        year = 2000 + int(year)
    else:
        year = int(year)
    month = int(numbers[indexes['M']])
    day = int(numbers[indexes['D']])
    if month > 12:
        month, day = day, month
    return date(year, month, day) 
開發者ID:Schibum,項目名稱:sndlatr,代碼行數:42,代碼來源:dates.py

示例15: get_day_of_year

# 需要導入模塊: from datetime import date [as 別名]
# 或者: from datetime.date import day [as 別名]
def get_day_of_year(self, date=None):
        if date is None:
            date = self.value
        return (date - date.replace(month=1, day=1)).days + 1 
開發者ID:Schibum,項目名稱:sndlatr,代碼行數:6,代碼來源:dates.py


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