Skip to content

Commit 3a6b274

Browse files
committed
Adds a DeprecationWarning when using classic formatter in from_format()
1 parent 48cdeb4 commit 3a6b274

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pendulum/pendulum.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import calendar
66
import datetime
7+
import warnings
78

89
import pendulum
910

@@ -398,6 +399,13 @@ def create_from_format(cls, time, fmt, tz=UTC, formatter='classic'):
398399
raise ValueError('Invalid formatter [{}]'.format(formatter))
399400

400401
if formatter == 'classic':
402+
warnings.warn(
403+
'Using the classic formatter in from_format() '
404+
'is deprecated and will no longer be possible '
405+
'in version 2.0. Use the alternative formatter instead.',
406+
DeprecationWarning,
407+
stacklevel=2
408+
)
401409
dt = datetime.datetime.strptime(time, fmt)
402410

403411
return cls.instance(dt, tz)
@@ -494,7 +502,9 @@ def create_from_timestamp(cls, timestamp, tz=UTC):
494502

495503
@classmethod
496504
def strptime(cls, time, fmt):
497-
return cls.create_from_format(time, fmt, formatter='classic')
505+
dt = datetime.datetime.strptime(time, fmt)
506+
507+
return cls.instance(dt)
498508

499509
def copy(self):
500510
"""

0 commit comments

Comments
 (0)