Skip to content

Commit ebe480a

Browse files
jbrockmendeljreback
authored andcommitted
use ccalendar instead of np_datetime (#21549)
1 parent 838e8da commit ebe480a

File tree

5 files changed

+5
-15
lines changed

5 files changed

+5
-15
lines changed

pandas/_libs/tslibs/ccalendar.pxd

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ from cython cimport Py_ssize_t
66
from numpy cimport int64_t, int32_t
77

88

9-
cdef int dayofweek(int y, int m, int m) nogil
9+
cdef int dayofweek(int y, int m, int d) nogil
1010
cdef bint is_leapyear(int64_t year) nogil
1111
cpdef int32_t get_days_in_month(int year, Py_ssize_t month) nogil
1212
cpdef int32_t get_week_of_year(int year, int month, int day) nogil

pandas/_libs/tslibs/np_datetime.pxd

-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ cdef extern from "../src/datetime/np_datetime.h":
5454
PANDAS_DATETIMEUNIT fr,
5555
pandas_datetimestruct *result) nogil
5656

57-
int days_per_month_table[2][12]
58-
int dayofweek(int y, int m, int d) nogil
59-
int is_leapyear(int64_t year) nogil
60-
6157

6258
cdef int reverse_ops[6]
6359

pandas/_libs/tslibs/offsets.pyx

+2-8
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ cnp.import_array()
1818
from util cimport is_string_object, is_integer_object
1919

2020
from ccalendar import MONTHS, DAYS
21+
from ccalendar cimport get_days_in_month, dayofweek
2122
from conversion cimport tz_convert_single, pydt_to_i8
2223
from frequencies cimport get_freq_code
2324
from nattype cimport NPY_NAT
2425
from np_datetime cimport (pandas_datetimestruct,
25-
dtstruct_to_dt64, dt64_to_dtstruct,
26-
is_leapyear, days_per_month_table, dayofweek)
26+
dtstruct_to_dt64, dt64_to_dtstruct)
2727

2828
# ---------------------------------------------------------------------
2929
# Constants
@@ -494,12 +494,6 @@ class BaseOffset(_BaseOffset):
494494
# ----------------------------------------------------------------------
495495
# RelativeDelta Arithmetic
496496

497-
@cython.wraparound(False)
498-
@cython.boundscheck(False)
499-
cdef inline int get_days_in_month(int year, int month) nogil:
500-
return days_per_month_table[is_leapyear(year)][month - 1]
501-
502-
503497
cdef inline int year_add_months(pandas_datetimestruct dts, int months) nogil:
504498
"""new year number after shifting pandas_datetimestruct number of months"""
505499
return dts.year + (dts.month + months - 1) / 12

pandas/_libs/tslibs/period.pyx

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ from timezones cimport is_utc, is_tzlocal, get_utcoffset, get_dst_info
4545
from timedeltas cimport delta_to_nanoseconds
4646

4747
cimport ccalendar
48-
from ccalendar cimport dayofweek, get_day_of_year
48+
from ccalendar cimport dayofweek, get_day_of_year, is_leapyear
4949
from ccalendar import MONTH_NUMBERS
50-
from ccalendar cimport is_leapyear
5150
from conversion cimport tz_convert_utc_to_tzlocal
5251
from frequencies cimport (get_freq_code, get_base_alias,
5352
get_to_timestamp_base, get_freq_str,

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ def pxd(name):
592592
'_libs.tslibs.offsets': {
593593
'pyxfile': '_libs/tslibs/offsets',
594594
'pxdfiles': ['_libs/src/util',
595+
'_libs/tslibs/ccalendar',
595596
'_libs/tslibs/conversion',
596597
'_libs/tslibs/frequencies',
597598
'_libs/tslibs/nattype'],

0 commit comments

Comments
 (0)