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


Python datetime.day方法代码示例

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


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

示例1: combine

# 需要导入模块: import datetime [as 别名]
# 或者: from datetime import day [as 别名]
def combine(self, other):
        """

        >>> dt = DayTimeToken(2018, 8, 18, 3, 0, 'pm')
        >>> day = DayToken(8, 20, 2018)
        >>> dt.combine(day)
        8/20/2018 3 pm
        >>> time = TimeToken(5, 'pm')
        >>> dt.combine(time)
        8/18/2018 5 pm
        """
        assert isinstance(other, (DayToken, TimeToken))
        if isinstance(other, DayToken):
            return other.combine(self.time)
        elif isinstance(other, TimeToken):
            self.time.apply(other)
            return self.day.combine(other) 
开发者ID:alvinwan,项目名称:timefhuman,代码行数:19,代码来源:data.py

示例2: datetime_from_timestamp

# 需要导入模块: import datetime [as 别名]
# 或者: from datetime import day [as 别名]
def datetime_from_timestamp(timestamp, offset=ZERO_TIMESPAN):
    """:yaql:datetime

    Returns datetime object built by timestamp.

    :signature: datetime(timestamp, offset => timespan(0))
    :arg timestamp: timespan object to represent datetime
    :argType timestamp: number
    :arg offset: datetime offset in microsecond resolution, needed for tzinfo,
        timespan(0) by default
    :argType offset: timespan type
    :returnType: datetime object

    .. code::

        yaql> let(datetime(1256953732)) -> [$.year, $.month, $.day]
        [2009, 10, 31]
    """
    zone = _get_tz(offset)
    return DATETIME_TYPE.fromtimestamp(timestamp, tz=zone) 
开发者ID:openstack,项目名称:yaql,代码行数:22,代码来源:date_time.py

示例3: now

# 需要导入模块: import datetime [as 别名]
# 或者: from datetime import day [as 别名]
def now(offset=ZERO_TIMESPAN):
    """:yaql:now

    Returns the current local date and time.

    :signature: now(offset => timespan(0))
    :arg offset: datetime offset in microsecond resolution, needed for tzinfo,
        timespan(0) by default
    :argType offset: timespan type
    :returnType: datetime

    .. code::

        yaql> let(now()) -> [$.year, $.month, $.day]
        [2016, 7, 18]
        yaql> now(offset=>localtz()).hour - now().hour
        3
    """
    zone = _get_tz(offset)
    return DATETIME_TYPE.now(tz=zone) 
开发者ID:openstack,项目名称:yaql,代码行数:22,代码来源:date_time.py

示例4: register

# 需要导入模块: import datetime [as 别名]
# 或者: from datetime import day [as 别名]
def register(context):
    functions = (
        build_datetime, build_timespan, datetime_from_timestamp,
        datetime_from_string, now, localtz, utctz, utc,
        days, hours, minutes, seconds, milliseconds, microseconds,
        datetime_plus_timespan, timespan_plus_datetime,
        datetime_minus_timespan, datetime_minus_datetime,
        timespan_plus_timespan, timespan_minus_timespan,
        datetime_gt_datetime, datetime_gte_datetime,
        datetime_lt_datetime, datetime_lte_datetime,
        timespan_gt_timespan, timespan_gte_timespan,
        timespan_lt_timespan, timespan_lte_timespan,
        negative_timespan, positive_timespan,
        timespan_by_num, num_by_timespan, div_timespans, div_timespan_by_num,
        year, month, day, hour, minute, second, microsecond, weekday,
        offset, timestamp, date, time, replace, format_, is_datetime,
        is_timespan
    )

    for func in functions:
        context.register_function(func) 
开发者ID:openstack,项目名称:yaql,代码行数:23,代码来源:date_time.py

示例5: check_date

# 需要导入模块: import datetime [as 别名]
# 或者: from datetime import day [as 别名]
def check_date(self, date):
        """This function checks if a specific date is an ANBIMA holiday or not
        
        Arguments:
            date : datetime object
                A Datetime Object which represents the date the user wants to check. 
        """

        if type(date) is datetime.day:
            y = date.year
            m = date.month
            d = date.day
            date = datetime.datetime(y, m, d)
        elif type(date) is not datetime.datetime:
            raise TypeError('Please input a Datetime object.')

        if date in self.holidays:
            return True
        return False 
开发者ID:Finance-Hub,项目名称:FinanceHub,代码行数:21,代码来源:AnbimaHolidays.py

示例6: __init__

# 需要导入模块: import datetime [as 别名]
# 或者: from datetime import day [as 别名]
def __init__(self, year, month, day, relative_hour, minute=0, time_of_day=None):
        self.day = DayToken(month, day, year)
        self.time = TimeToken(relative_hour, time_of_day, minute) 
开发者ID:alvinwan,项目名称:timefhuman,代码行数:5,代码来源:data.py

示例7: datetime

# 需要导入模块: import datetime [as 别名]
# 或者: from datetime import day [as 别名]
def datetime(self, now):
        # TODO: handle Nones
        return datetime.datetime(
            self.day.year, self.day.month, self.day.day, self.time.hour, self.time.minute) 
开发者ID:alvinwan,项目名称:timefhuman,代码行数:6,代码来源:data.py

示例8: from_day_time

# 需要导入模块: import datetime [as 别名]
# 或者: from datetime import day [as 别名]
def from_day_time(day, time):
        return DayTimeToken(
            day.year, day.month, day.day, time.relative_hour, time.minute,
            time.time_of_day) 
开发者ID:alvinwan,项目名称:timefhuman,代码行数:6,代码来源:data.py

示例9: __repr__

# 需要导入模块: import datetime [as 别名]
# 或者: from datetime import day [as 别名]
def __repr__(self):
        return '{} {}'.format(repr(self.day), repr(self.time)) 
开发者ID:alvinwan,项目名称:timefhuman,代码行数:4,代码来源:data.py

示例10: __add__

# 需要导入模块: import datetime [as 别名]
# 或者: from datetime import day [as 别名]
def __add__(self, other):
        """
        >>> d1 = DayToken(3, 2, None)
        >>> d1 + 3
        3/5
        """
        assert isinstance(other, int)
        return DayToken(self.month, self.day + other, self.year) 
开发者ID:alvinwan,项目名称:timefhuman,代码行数:10,代码来源:data.py

示例11: __radd__

# 需要导入模块: import datetime [as 别名]
# 或者: from datetime import day [as 别名]
def __radd__(self, other):
        """
        >>> d1 = DayToken(3, 2, None)
        >>> 3 + d1
        3/5
        """
        assert isinstance(other, int)
        return DayToken(self.month, self.day + other, self.year) 
开发者ID:alvinwan,项目名称:timefhuman,代码行数:10,代码来源:data.py

示例12: __eq__

# 需要导入模块: import datetime [as 别名]
# 或者: from datetime import day [as 别名]
def __eq__(self, other):
        """
        >>> DayToken(5, 7, 2018) == DayToken(5, 7, 2018)
        True
        >>> DayToken(7, 4, 2018) == DayToken(7, 6, 2018)
        False
        """
        if not isinstance(other, DayToken):
            return False
        return self.month == other.month and self.day == other.day and \
            self.year == other.year 
开发者ID:alvinwan,项目名称:timefhuman,代码行数:13,代码来源:data.py

示例13: test_julian_day_dt

# 需要导入模块: import datetime [as 别名]
# 或者: from datetime import day [as 别名]
def test_julian_day_dt(self):
        # add 1us manually to the test timestamp (GH #940)
        dt = times.tz_convert('UTC')[0] + pd.Timedelta(1, unit='us')
        year = dt.year
        month = dt.month
        day = dt.day
        hour = dt.hour
        minute = dt.minute
        second = dt.second
        microsecond = dt.microsecond
        assert_almost_equal(JD + 1e-6 / (3600*24),  # modify expected JD by 1us
                            self.spa.julian_day_dt(
                                year, month, day, hour,
                                minute, second, microsecond), 6) 
开发者ID:pvlib,项目名称:pvlib-python,代码行数:16,代码来源:test_spa.py

示例14: build_datetime

# 需要导入模块: import datetime [as 别名]
# 或者: from datetime import day [as 别名]
def build_datetime(year, month, day, hour=0, minute=0, second=0,
                   microsecond=0, offset=ZERO_TIMESPAN):
    """:yaql:datetime

    Returns datetime object built on year, month, day, hour, minute, second,
    microsecond, offset.

    :signature: datetime(year, month, day, hour => 0, minute => 0, second => 0,
                         microsecond => 0, offset => timespan(0))
    :arg year: number of years in datetime
    :argType year: integer between 1 and 9999 inclusive
    :arg month: number of months in datetime
    :argType month: integer between 1 and 12 inclusive
    :arg day: number of days in datetime
    :argType day: integer between 1 and number of days in given month
    :arg hour: number of hours in datetime, 0 by default
    :argType hour: integer between 0 and 23 inclusive
    :arg minute: number of minutes in datetime, 0 by default
    :argType minute: integer between 0 and 59 inclusive
    :arg second: number of seconds in datetime, 0 by default
    :argType second: integer between 0 and 59 inclusive
    :arg microsecond: number of microseconds in datetime, 0 by default
    :argType microsecond: integer between 0 and 1000000-1
    :arg offset: datetime offset in microsecond resolution, needed for tzinfo,
        timespan(0) by default
    :argType offset: timespan type
    :returnType: datetime object

    .. code::

        yaql> let(datetime(2015, 9, 29)) -> [$.year, $.month, $.day]
        [2015, 9, 29]
    """
    zone = _get_tz(offset)
    return DATETIME_TYPE(year, month, day, hour, minute, second,
                         microsecond, zone) 
开发者ID:openstack,项目名称:yaql,代码行数:38,代码来源:date_time.py

示例15: datetime_from_string

# 需要导入模块: import datetime [as 别名]
# 或者: from datetime import day [as 别名]
def datetime_from_string(string, format__=None):
    """:yaql:datetime

    Returns datetime object built by string parsed with format.

    :signature: datetime(string, format => null)
    :arg string: string representing datetime
    :argType string: string
    :arg format: format for parsing input string which should be supported
        with C99 standard of format codes. null by default, which means
        parsing with Python dateutil.parser usage
    :argType format: string
    :returnType: datetime object

    .. code::

        yaql> let(datetime("29.8?2015")) -> [$.year, $.month, $.day]
        [2015, 8, 29]
        yaql> let(datetime("29.8?2015", "%d.%m?%Y"))->[$.year, $.month, $.day]
        [2015, 8, 29]
    """
    if not format__:
        result = parser.parse(string)
    else:
        result = DATETIME_TYPE.strptime(string, format__)
    if not result.tzinfo:
        return result.replace(tzinfo=UTCTZ)
    return result 
开发者ID:openstack,项目名称:yaql,代码行数:30,代码来源:date_time.py


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