Skip to content

Commit 22cf8a5

Browse files
author
Matt Roeschke
committed
refactor constructor with args
1 parent 795aa19 commit 22cf8a5

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

pandas/_libs/tslibs/timestamps.pyx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,9 @@ class Timestamp(_Timestamp):
700700
elif tz is not None:
701701
raise ValueError('Can provide at most one of tz, tzinfo')
702702

703+
# User passed tzinfo instead of tz; avoid silently ignoring
704+
tz, tzinfo = tzinfo, None
705+
703706
if is_string_object(ts_input):
704707
# User passed a date string to parse.
705708
# Check that the user didn't also pass a date attribute kwarg.
@@ -709,21 +712,18 @@ class Timestamp(_Timestamp):
709712

710713
elif ts_input is _no_input:
711714
# User passed keyword arguments.
712-
return Timestamp(datetime(year, month, day, hour or 0,
713-
minute or 0, second or 0,
714-
microsecond or 0, tzinfo),
715-
nanosecond=nanosecond, tz=tz)
715+
ts_input = datetime(year, month, day, hour or 0,
716+
minute or 0, second or 0,
717+
microsecond or 0)
716718
elif is_integer_object(freq):
717719
# User passed positional arguments:
718720
# Timestamp(year, month, day[, hour[, minute[, second[,
719721
# microsecond[, nanosecond[, tzinfo]]]]]])
720-
return Timestamp(datetime(ts_input, freq, tz, unit or 0,
721-
year or 0, month or 0, day or 0,
722-
minute), nanosecond=hour)
723-
724-
if tzinfo is not None:
725-
# User passed tzinfo instead of tz; avoid silently ignoring
726-
tz, tzinfo = tzinfo, None
722+
ts_input = datetime(ts_input, freq, tz, unit or 0,
723+
year or 0, month or 0, day or 0)
724+
nanosecond = hour
725+
tz = minute
726+
freq = None
727727

728728
if getattr(ts_input, 'tzinfo', None) is not None and tz is not None:
729729
warnings.warn("Passing a datetime or Timestamp with tzinfo and the"

0 commit comments

Comments
 (0)