diff --git a/pandas/_libs/tslibs/ccalendar.pyx b/pandas/_libs/tslibs/ccalendar.pyx index 9f8cf6c28adab..de8fd3911e946 100644 --- a/pandas/_libs/tslibs/ccalendar.pyx +++ b/pandas/_libs/tslibs/ccalendar.pyx @@ -7,11 +7,6 @@ import cython from numpy cimport int64_t, int32_t -from locale import LC_TIME - -from pandas._config.localization import set_locale -from pandas._libs.tslibs.strptime import LocaleTime - # ---------------------------------------------------------------------- # Constants @@ -246,21 +241,3 @@ cpdef int32_t get_day_of_year(int year, int month, int day) nogil: day_of_year = mo_off + day return day_of_year - - -def get_locale_names(name_type: str, locale: object = None): - """ - Returns an array of localized day or month names. - - Parameters - ---------- - name_type : string, attribute of LocaleTime() in which to return localized - names - locale : string - - Returns - ------- - list of locale names - """ - with set_locale(locale, LC_TIME): - return getattr(LocaleTime(), name_type) diff --git a/pandas/_libs/tslibs/fields.pyx b/pandas/_libs/tslibs/fields.pyx index 126deb67e4189..2351aca749dcc 100644 --- a/pandas/_libs/tslibs/fields.pyx +++ b/pandas/_libs/tslibs/fields.pyx @@ -2,6 +2,7 @@ Functions for accessing attributes of Timestamp/datetime64/datetime-like objects and arrays """ +from locale import LC_TIME import cython from cython import Py_ssize_t @@ -11,9 +12,9 @@ cimport numpy as cnp from numpy cimport ndarray, int64_t, int32_t, int8_t, uint32_t cnp.import_array() -from pandas._libs.tslibs.ccalendar import ( - get_locale_names, MONTHS_FULL, DAYS_FULL, -) +from pandas._config.localization import set_locale + +from pandas._libs.tslibs.ccalendar import MONTHS_FULL, DAYS_FULL from pandas._libs.tslibs.ccalendar cimport ( DAY_NANOS, get_days_in_month, is_leapyear, dayofweek, get_week_of_year, @@ -24,6 +25,7 @@ from pandas._libs.tslibs.np_datetime cimport ( npy_datetimestruct, pandas_timedeltastruct, dt64_to_dtstruct, td64_to_tdstruct) from pandas._libs.tslibs.nattype cimport NPY_NAT +from pandas._libs.tslibs.strptime import LocaleTime def get_time_micros(const int64_t[:] dtindex): @@ -704,3 +706,21 @@ def build_isocalendar_sarray(const int64_t[:] dtindex): iso_weeks[i] = ret_val[1] days[i] = ret_val[2] return out + + +def get_locale_names(name_type: str, locale: object = None): + """ + Returns an array of localized day or month names. + + Parameters + ---------- + name_type : string, attribute of LocaleTime() in which to return localized + names + locale : string + + Returns + ------- + list of locale names + """ + with set_locale(locale, LC_TIME): + return getattr(LocaleTime(), name_type)