@@ -5,7 +5,7 @@ import locale
5
5
import calendar
6
6
import re
7
7
8
- from cpython cimport datetime
8
+ from cpython.datetime cimport date, tzinfo
9
9
10
10
from _thread import allocate_lock as _thread_allocate_lock
11
11
@@ -291,20 +291,20 @@ def array_strptime(object[:] values, object fmt, bint exact=True, errors='raise'
291
291
elif iso_year != - 1 and iso_week != - 1 :
292
292
year, julian = _calc_julian_from_V(iso_year, iso_week,
293
293
weekday + 1 )
294
- # Cannot pre-calculate datetime. date() since can change in Julian
294
+ # Cannot pre-calculate date() since can change in Julian
295
295
# calculation and thus could have different value for the day of the wk
296
296
# calculation.
297
297
try :
298
298
if julian == - 1 :
299
299
# Need to add 1 to result since first day of the year is 1, not
300
300
# 0.
301
- ordinal = datetime. date(year, month, day).toordinal()
302
- julian = ordinal - datetime. date(year, 1 , 1 ).toordinal() + 1
301
+ ordinal = date(year, month, day).toordinal()
302
+ julian = ordinal - date(year, 1 , 1 ).toordinal() + 1
303
303
else :
304
304
# Assume that if they bothered to include Julian day it will
305
305
# be accurate.
306
- datetime_result = datetime. date.fromordinal(
307
- (julian - 1 ) + datetime. date(year, 1 , 1 ).toordinal())
306
+ datetime_result = date.fromordinal(
307
+ (julian - 1 ) + date(year, 1 , 1 ).toordinal())
308
308
year = datetime_result.year
309
309
month = datetime_result.month
310
310
day = datetime_result.day
@@ -314,7 +314,7 @@ def array_strptime(object[:] values, object fmt, bint exact=True, errors='raise'
314
314
continue
315
315
raise
316
316
if weekday == - 1 :
317
- weekday = datetime. date(year, month, day).weekday()
317
+ weekday = date(year, month, day).weekday()
318
318
319
319
dts.year = year
320
320
dts.month = month
@@ -652,7 +652,7 @@ cdef int _calc_julian_from_U_or_W(int year, int week_of_year,
652
652
cdef:
653
653
int first_weekday, week_0_length, days_to_week
654
654
655
- first_weekday = datetime. date(year, 1 , 1 ).weekday()
655
+ first_weekday = date(year, 1 , 1 ).weekday()
656
656
# If we are dealing with the %U directive (week starts on Sunday), it's
657
657
# easier to just shift the view to Sunday being the first day of the
658
658
# week.
@@ -695,18 +695,18 @@ cdef (int, int) _calc_julian_from_V(int iso_year, int iso_week, int iso_weekday)
695
695
cdef:
696
696
int correction, ordinal
697
697
698
- correction = datetime. date(iso_year, 1 , 4 ).isoweekday() + 3
698
+ correction = date(iso_year, 1 , 4 ).isoweekday() + 3
699
699
ordinal = (iso_week * 7 ) + iso_weekday - correction
700
700
# ordinal may be negative or 0 now, which means the date is in the previous
701
701
# calendar year
702
702
if ordinal < 1 :
703
- ordinal += datetime. date(iso_year, 1 , 1 ).toordinal()
703
+ ordinal += date(iso_year, 1 , 1 ).toordinal()
704
704
iso_year -= 1
705
- ordinal -= datetime. date(iso_year, 1 , 1 ).toordinal()
705
+ ordinal -= date(iso_year, 1 , 1 ).toordinal()
706
706
return iso_year, ordinal
707
707
708
708
709
- cdef parse_timezone_directive(str z):
709
+ cdef tzinfo parse_timezone_directive(str z):
710
710
"""
711
711
Parse the '%z ' directive and return a pytz.FixedOffset
712
712
0 commit comments