Skip to content
New: Star-import, signal unraveling, Python 3.12 support, and more

#
datetime_nb module

Numba-compiled utilities for working with dates and time.

## DTCS DTCST

Status returned by within_fixed_dtc_nb() and within_periodic_dtc_nb().

    DTCST(
        SU=-3,
        EU=-2,
        U=-1,
        O=0,
        I=1
    )

Attributes

`SU`
  Start matched, rest unknown. Move down the stack.
`EU`
  End matched, rest unknown. Move down the stack.
`U`
  Unknown. Move down the stack.
`O`
  Outside
`I`
  Inside

## d_ns int

Day (nanoseconds).

## d_td timedelta64

Day (timedelta).

## h_ns int

Hour (nanoseconds).

## h_td timedelta64

Hour (timedelta).

## m_ns int

Minute (nanoseconds).

## m_td timedelta64

Minute (timedelta).

## mo_ns int

Month (nanoseconds).

## mo_td timedelta64

Month (timedelta).

## ms_ns int

Millisecond (nanoseconds).

## ms_td timedelta64

Millisecond (timedelta).

## ns_td timedelta64

Nanosecond (timedelta).

## q_ns int

Quarter (nanoseconds).

## q_td timedelta64

Quarter (timedelta).

## s_ns int

Second (nanoseconds).

## s_td timedelta64

Second (timedelta).

## semi_mo_ns int

Semi-month (nanoseconds).

## semi_mo_td timedelta64

Semi-month (timedelta).

## unix_epoch_dt datetime64

Unix epoch (datetime).

## us_ns int

Microsecond (nanoseconds).

## us_td timedelta64

Microsecond (timedelta).

## w_ns int

Week (nanoseconds).

## w_td timedelta64

Week (timedelta).

## y_ns int

Year (nanoseconds).

## y_td timedelta64

Year (timedelta).

## day_changed_nb function

    day_changed_nb(
        ts1,
        ts2
    )

Whether the day changed.

## day_nb function

    day_nb(
        ts
    )

Get the day of the month.

## day_of_year_nb function

    day_of_year_nb(
        ts
    )

Get the day of the year.

## days_nb function

    days_nb(
        ts
    )

Get the number of days.

## from_civil_nb function

    from_civil_nb(
        y,
        m,
        d
    )

Convert a year, month, and day into the timestamp.

## future_weekday_nb function

    future_weekday_nb(
        ts,
        weekday,
        zero_start=True
    )

Get the timestamp of a weekday in the future.

## hour_nb function

    hour_nb(
        ts
    )

Get the hour.

## hours_nb function

    hours_nb(
        ts
    )

Get the number of hours.

## index_matches_dtc_nb function

    index_matches_dtc_nb(
        index,
        other_dtc
    )

Run matches_dtc_nb() on each element in an index and return a mask.

## index_within_dtc_range_nb function

    index_within_dtc_range_nb(
        index,
        start_dtc,
        end_dtc,
        closed_start=True,
        closed_end=False
    )

Run within_dtc_range_nb() on each element in an index and return a mask.

## is_leap_year_nb function

    is_leap_year_nb(
        y
    )

Get whether the year is a leap year.

## last_day_of_month_nb function

    last_day_of_month_nb(
        y,
        m
    )

Get the last day of the month.

## matches_date_nb function

    matches_date_nb(
        ts,
        y,
        m,
        d
    )

Check whether the timestamp match the date provided in the civil format.

## matches_dtc_nb function

    matches_dtc_nb(
        dtc,
        other_dtc
    )

Return whether one or more datetime components match other components.

## microsecond_nb function

    microsecond_nb(
        ts
    )

Get the microsecond.

## microseconds_nb function

    microseconds_nb(
        ts
    )

Get the number of microseconds.

## midnight_nb function

    midnight_nb(
        ts
    )

Get the midnight of this day.

## millisecond_nb function

    millisecond_nb(
        ts
    )

Get the millisecond.

## milliseconds_nb function

    milliseconds_nb(
        ts
    )

Get the number of milliseconds.

## minute_nb function

    minute_nb(
        ts
    )

Get the minute.

## minutes_nb function

    minutes_nb(
        ts
    )

Get the number of minutes.

## month_nb function

    month_nb(
        ts
    )

Get the month of the year.

## must_resolve_dtc_nb function

    must_resolve_dtc_nb(
        c=None,
        start_c=None,
        end_c=None
    )

Return whether the component must be resolved.

## nanosecond_nb function

    nanosecond_nb(
        ts
    )

Get the nanosecond.

## past_weekday_nb function

    past_weekday_nb(
        ts,
        weekday,
        zero_start=True
    )

Get the timestamp of a weekday in the past.

## second_nb function

    second_nb(
        ts
    )

Get the seconds.

## second_remainder_nb function

    second_remainder_nb(
        ts
    )

Get the nanosecond remainder after the second.

## seconds_nb function

    seconds_nb(
        ts
    )

Get the number of seconds.

## start_dtc_eq_nb function

    start_dtc_eq_nb(
        c=None,
        start_c=None,
        end_c=None
    )

Return whether the start component equals to the end component.

## start_dtc_gt_nb function

    start_dtc_gt_nb(
        c=None,
        start_c=None,
        end_c=None
    )

Return whether the start component is greater than the end component.

## start_dtc_lt_nb function

    start_dtc_lt_nb(
        c=None,
        start_c=None,
        end_c=None
    )

Return whether the start component is less than the end component.

## to_civil_nb function

    to_civil_nb(
        ts
    )

Convert a timestamp into a tuple of the year, month, and day.

## week_nb function

    week_nb(
        ts
    )

Get the week of the year.

## weekday_diff_nb function

    weekday_diff_nb(
        weekday1,
        weekday2,
        zero_start=True
    )

Get the difference in days between two weekdays.

## weekday_from_days_nb function

    weekday_from_days_nb(
        days,
        zero_start=True
    )

Get the weekday from the total number of days.

Weekdays are ranging from 0 (Monday) to 6 (Sunday).

## weekday_nb function

    weekday_nb(
        ts,
        zero_start=True
    )

Get the weekday.

Weekdays are ranging from 0 (Monday) to 6 (Sunday).

## within_dtc_range_nb function

    within_dtc_range_nb(
        dtc,
        start_dtc,
        end_dtc,
        closed_start=True,
        closed_end=False
    )

Return whether one or more datetime components are within a range.

## within_fixed_dtc_nb function

    within_fixed_dtc_nb(
        c,
        start_c=None,
        end_c=None,
        prev_status=-1,
        closed_start=True,
        closed_end=False,
        is_last=False
    )

Return whether a single datetime component is within a fixed range.

Returns a status of the type DTCS.

## within_periodic_dtc_nb function

    within_periodic_dtc_nb(
        c,
        start_c=None,
        end_c=None,
        prev_status=-1,
        closed_start=True,
        closed_end=False,
        overflow_later=False,
        is_last=False
    )

Return whether a single datetime component is within a periodic range.

Returns a status of the type DTCS.

## year_nb function

    year_nb(
        ts
    )

Get the year.

## DTCST class

    DTCST(
        SU=-3,
        EU=-2,
        U=-1,
        O=0,
        I=1
    )

DTCST(SU, EU, U, O, I)

Superclasses

- `builtins.tuple`

### EU method-wrapper

Alias for field number 1

### I method-wrapper

Alias for field number 4

### O method-wrapper

Alias for field number 3

### SU method-wrapper

Alias for field number 0

### U method-wrapper

Alias for field number 2

#### Cookie consent

We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better.

- Google Analytics
- GitHub

Manage settings