2
2
Functions for accessing attributes of Timestamp/datetime64/datetime-like
3
3
objects and arrays
4
4
"""
5
+ from locale import LC_TIME
5
6
6
7
import cython
7
8
from cython import Py_ssize_t
@@ -11,9 +12,9 @@ cimport numpy as cnp
11
12
from numpy cimport ndarray, int64_t, int32_t, int8_t, uint32_t
12
13
cnp.import_array()
13
14
14
- from pandas._libs.tslibs.ccalendar import (
15
- get_locale_names, MONTHS_FULL, DAYS_FULL,
16
- )
15
+ from pandas._config.localization import set_locale
16
+
17
+ from pandas._libs.tslibs.ccalendar import MONTHS_FULL, DAYS_FULL
17
18
from pandas._libs.tslibs.ccalendar cimport (
18
19
DAY_NANOS,
19
20
get_days_in_month, is_leapyear, dayofweek, get_week_of_year,
@@ -24,6 +25,7 @@ from pandas._libs.tslibs.np_datetime cimport (
24
25
npy_datetimestruct, pandas_timedeltastruct, dt64_to_dtstruct,
25
26
td64_to_tdstruct)
26
27
from pandas._libs.tslibs.nattype cimport NPY_NAT
28
+ from pandas._libs.tslibs.strptime import LocaleTime
27
29
28
30
29
31
def get_time_micros (const int64_t[:] dtindex ):
@@ -704,3 +706,21 @@ def build_isocalendar_sarray(const int64_t[:] dtindex):
704
706
iso_weeks[i] = ret_val[1 ]
705
707
days[i] = ret_val[2 ]
706
708
return out
709
+
710
+
711
+ def get_locale_names (name_type: str , locale: object = None ):
712
+ """
713
+ Returns an array of localized day or month names.
714
+
715
+ Parameters
716
+ ----------
717
+ name_type : string, attribute of LocaleTime() in which to return localized
718
+ names
719
+ locale : string
720
+
721
+ Returns
722
+ -------
723
+ list of locale names
724
+ """
725
+ with set_locale(locale, LC_TIME):
726
+ return getattr (LocaleTime(), name_type)
0 commit comments