Skip to content

Commit d454b30

Browse files
ShaharNavehSeeminSyed
authored andcommitted
CLN: Using clearer imports (pandas-dev#32459)
Co-authored-by: MomIsBestFriend <>
1 parent e5a213b commit d454b30

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

pandas/_libs/tslibs/strptime.pyx

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import time
44
import locale
55
import calendar
66
import re
7-
from datetime import date as datetime_date
7+
import datetime
88

99
from _thread import allocate_lock as _thread_allocate_lock
1010

@@ -288,20 +288,20 @@ def array_strptime(object[:] values, object fmt, bint exact=True, errors='raise'
288288
elif iso_year != -1 and iso_week != -1:
289289
year, julian = _calc_julian_from_V(iso_year, iso_week,
290290
weekday + 1)
291-
# Cannot pre-calculate datetime_date() since can change in Julian
291+
# Cannot pre-calculate datetime.date() since can change in Julian
292292
# calculation and thus could have different value for the day of the wk
293293
# calculation.
294294
try:
295295
if julian == -1:
296296
# Need to add 1 to result since first day of the year is 1, not
297297
# 0.
298-
ordinal = datetime_date(year, month, day).toordinal()
299-
julian = ordinal - datetime_date(year, 1, 1).toordinal() + 1
298+
ordinal = datetime.date(year, month, day).toordinal()
299+
julian = ordinal - datetime.date(year, 1, 1).toordinal() + 1
300300
else:
301301
# Assume that if they bothered to include Julian day it will
302302
# be accurate.
303-
datetime_result = datetime_date.fromordinal(
304-
(julian - 1) + datetime_date(year, 1, 1).toordinal())
303+
datetime_result = datetime.date.fromordinal(
304+
(julian - 1) + datetime.date(year, 1, 1).toordinal())
305305
year = datetime_result.year
306306
month = datetime_result.month
307307
day = datetime_result.day
@@ -311,7 +311,7 @@ def array_strptime(object[:] values, object fmt, bint exact=True, errors='raise'
311311
continue
312312
raise
313313
if weekday == -1:
314-
weekday = datetime_date(year, month, day).weekday()
314+
weekday = datetime.date(year, month, day).weekday()
315315

316316
dts.year = year
317317
dts.month = month
@@ -649,7 +649,7 @@ cdef int _calc_julian_from_U_or_W(int year, int week_of_year,
649649
cdef:
650650
int first_weekday, week_0_length, days_to_week
651651

652-
first_weekday = datetime_date(year, 1, 1).weekday()
652+
first_weekday = datetime.date(year, 1, 1).weekday()
653653
# If we are dealing with the %U directive (week starts on Sunday), it's
654654
# easier to just shift the view to Sunday being the first day of the
655655
# week.
@@ -692,14 +692,14 @@ cdef (int, int) _calc_julian_from_V(int iso_year, int iso_week, int iso_weekday)
692692
cdef:
693693
int correction, ordinal
694694

695-
correction = datetime_date(iso_year, 1, 4).isoweekday() + 3
695+
correction = datetime.date(iso_year, 1, 4).isoweekday() + 3
696696
ordinal = (iso_week * 7) + iso_weekday - correction
697697
# ordinal may be negative or 0 now, which means the date is in the previous
698698
# calendar year
699699
if ordinal < 1:
700-
ordinal += datetime_date(iso_year, 1, 1).toordinal()
700+
ordinal += datetime.date(iso_year, 1, 1).toordinal()
701701
iso_year -= 1
702-
ordinal -= datetime_date(iso_year, 1, 1).toordinal()
702+
ordinal -= datetime.date(iso_year, 1, 1).toordinal()
703703
return iso_year, ordinal
704704

705705

0 commit comments

Comments
 (0)