@@ -107,6 +107,7 @@ cdef class _Timestamp(datetime):
107
107
cdef readonly:
108
108
int64_t value, nanosecond
109
109
object freq # frequency reference
110
+ list _date_attributes
110
111
111
112
def __hash__ (_Timestamp self ):
112
113
if self .nanosecond:
@@ -425,10 +426,10 @@ class Timestamp(_Timestamp):
425
426
.. versionadded:: 0.19.0
426
427
hour, minute, second, microsecond : int, optional, default 0
427
428
.. versionadded:: 0.19.0
428
- tzinfo : datetime.tzinfo, optional, default None
429
- .. versionadded:: 0.19.0
430
429
nanosecond : int, optional, default 0
431
430
.. versionadded:: 0.23.0
431
+ tzinfo : datetime.tzinfo, optional, default None
432
+ .. versionadded:: 0.19.0
432
433
433
434
Notes
434
435
-----
@@ -558,7 +559,7 @@ class Timestamp(_Timestamp):
558
559
object freq = None , tz = None , unit = None ,
559
560
year = None , month = None , day = None ,
560
561
hour = None , minute = None , second = None , microsecond = None ,
561
- tzinfo = None , nanosecond = None ):
562
+ nanosecond = None , tzinfo = None ):
562
563
# The parameter list folds together legacy parameter names (the first
563
564
# four) and positional and keyword parameter names from pydatetime.
564
565
#
@@ -582,6 +583,9 @@ class Timestamp(_Timestamp):
582
583
583
584
cdef _TSObject ts
584
585
586
+ _date_attributes = [year, month, day, hour, minute, second,
587
+ microsecond, nanosecond]
588
+
585
589
if tzinfo is not None :
586
590
if not PyTZInfo_Check(tzinfo):
587
591
# tzinfo must be a datetime.tzinfo object, GH#17690
@@ -593,9 +597,9 @@ class Timestamp(_Timestamp):
593
597
if is_string_object(ts_input):
594
598
# User passed a date string to parse.
595
599
# Check that the user didn't also pass a date attribute kwarg.
596
- date_attrs = [year, month, day, hour, minute, second, microsecond,
597
- nanosecond]
598
- if any (arg is not None for arg in date_attrs ):
600
+ # date_attrs = [year, month, day, hour, minute, second, microsecond,
601
+ # nanosecond]
602
+ if any (arg is not None for arg in _date_attributes ):
599
603
raise ValueError (' Cannot pass a date attribute keyword '
600
604
' argument when passing a date string' )
601
605
@@ -611,10 +615,10 @@ class Timestamp(_Timestamp):
611
615
elif is_integer_object(freq):
612
616
# User passed positional arguments:
613
617
# Timestamp(year, month, day[, hour[, minute[, second[,
614
- # microsecond[, tzinfo]]]]])
618
+ # microsecond[, nanosecond[, tzinfo] ]]]]])
615
619
return Timestamp(datetime(ts_input, freq, tz, unit or 0 ,
616
620
year or 0 , month or 0 , day or 0 ,
617
- hour ), nanosecond = minute , tz = hour )
621
+ minute ), nanosecond = hour , tz = minute )
618
622
619
623
if tzinfo is not None :
620
624
# User passed tzinfo instead of tz; avoid silently ignoring
0 commit comments