@@ -21,11 +21,10 @@ from util cimport (is_datetime64_object, is_timedelta64_object,
21
21
INT64_MAX)
22
22
23
23
cimport ccalendar
24
- from ccalendar import get_locale_names, MONTHS_FULL, DAYS_FULL
25
24
from conversion import tz_localize_to_utc, date_normalize
26
25
from conversion cimport (tz_convert_single, _TSObject,
27
26
convert_to_tsobject, convert_datetime_to_tsobject)
28
- from fields import get_date_field, get_start_end_field
27
+ from fields import get_start_end_field, get_date_name_field
29
28
from nattype import NaT
30
29
from nattype cimport NPY_NAT
31
30
from np_datetime import OutOfBoundsDatetime
@@ -352,6 +351,16 @@ cdef class _Timestamp(datetime):
352
351
field, freqstr, month_kw)
353
352
return out[0 ]
354
353
354
+ cpdef _get_date_name_field(self , object field, object locale):
355
+ cdef:
356
+ int64_t val
357
+ ndarray out
358
+
359
+ val = self ._maybe_convert_value_to_local()
360
+ out = get_date_name_field(np.array([val], dtype = np.int64),
361
+ field, locale = locale)
362
+ return out[0 ]
363
+
355
364
@property
356
365
def _repr_base (self ):
357
366
return ' {date} {time}' .format(date = self ._date_repr,
@@ -702,45 +711,39 @@ class Timestamp(_Timestamp):
702
711
def dayofweek (self ):
703
712
return self .weekday()
704
713
705
- def day_name (self , time_locale = None ):
714
+ def day_name (self , locale = None ):
706
715
"""
707
716
Return the day name of the Timestamp with specified locale.
708
717
709
718
Parameters
710
719
----------
711
- time_locale : string, default None (English locale)
720
+ locale : string, default None (English locale)
712
721
locale determining the language in which to return the day name
713
722
714
723
Returns
715
724
-------
716
725
day_name : string
726
+
727
+ .. versionadded:: 0.23.0
717
728
"""
718
- if time_locale is None :
719
- names = DAYS_FULL
720
- else :
721
- names = get_locale_names(' f_weekday' , time_locale)
722
- days = dict (enumerate (names))
723
- return days[self .weekday()].capitalize()
729
+ return self ._get_date_name_field(' day_name' , locale)
724
730
725
- def month_name (self , time_locale = None ):
731
+ def month_name (self , locale = None ):
726
732
"""
727
733
Return the month name of the Timestamp with specified locale.
728
734
729
735
Parameters
730
736
----------
731
- time_locale : string, default None (English locale)
737
+ locale : string, default None (English locale)
732
738
locale determining the language in which to return the month name
733
739
734
740
Returns
735
741
-------
736
742
month_name : string
743
+
744
+ .. versionadded:: 0.23.0
737
745
"""
738
- if time_locale is None :
739
- names = MONTHS_FULL
740
- else :
741
- names = get_locale_names(' f_month' , time_locale)
742
- months = dict (enumerate (names))
743
- return months[self .month].capitalize()
746
+ return self ._get_date_name_field(' month_name' , locale)
744
747
745
748
@property
746
749
def weekday_name (self ):
0 commit comments