Skip to content

Commit 6cab171

Browse files
amanda11cognifloyd
andauthored
Move to ciso8601 for datetime (#5692)
* Move to ciso8601 for datetime * Add PR to changelog * Needed to remove err that was added for debugging Co-authored-by: Jacob Floyd <[email protected]>
1 parent e187300 commit 6cab171

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Added
3636
* Add ``ST2_USE_DEBUGGER`` env var as alternative to the ``--use-debugger`` cli flag. #5675
3737
Contributed by @cognifloyd
3838

39-
* Added purging of old tokens. #56791
39+
* Added purging of old tokens. #5679
4040
Contributed by Amanda McGuinness (@amanda11 intive)
4141

4242
Changed
@@ -87,6 +87,10 @@ Changed
8787

8888
Contributed by @cognifloyd
8989

90+
* Move from udatetime to ciso8601 for date functionality ahead of supporting python3.9 #5692
91+
Contributed by Amanda McGuinness (@amanda11 intive)
92+
93+
9094
Removed
9195
~~~~~~~
9296

fixed-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,3 @@ psutil==5.8.0
8282
python-dateutil==2.8.1
8383
python-statsd==2.1.0
8484
orjson==3.5.2
85-
udatetime==0.0.16

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ argcomplete==1.12.2
1313
bcrypt==3.2.0
1414
cffi<1.15.0
1515
chardet<3.1.0
16+
ciso8601
1617
cryptography==3.4.7
1718
decorator==4.4.2
1819
dnspython>=1.16.0,<2.0.0
@@ -73,7 +74,6 @@ stevedore==1.30.1
7374
tenacity>=3.2.1,<7.0.0
7475
tooz==2.8.0
7576
typing-extensions<4.2
76-
udatetime==0.0.16
7777
unittest2
7878
webob==1.8.7
7979
webtest

st2common/in-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ webob
4242
jsonpath-rw
4343
pyOpenSSL
4444
python-statsd
45-
udatetime
45+
ciso8601
4646
orjson
4747
# Note: amqp is used by kombu, this needs to be added here to be picked up by
4848
# requirements fixate script.

st2common/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ amqp==5.0.6
1010
apscheduler==3.7.0
1111
cffi<1.15.0
1212
chardet<3.1.0
13+
ciso8601
1314
cryptography==3.4.7
1415
decorator==4.4.2
1516
dnspython>=1.16.0,<2.0.0
@@ -43,7 +44,6 @@ six==1.13.0
4344
st2-rbac-backend@ git+https://github.com/StackStorm/st2-rbac-backend.git@master
4445
tenacity>=3.2.1,<7.0.0
4546
tooz==2.8.0
46-
udatetime==0.0.16
4747
webob==1.8.7
4848
zake==0.2.2
4949
zstandard==0.15.2

st2common/st2common/util/date.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import datetime
2323

24-
import udatetime
24+
import ciso8601
2525

2626
import dateutil.tz
2727
import dateutil.parser
@@ -83,16 +83,13 @@ def parse(value, preserve_original_tz=False):
8383
8484
:rtype: ``datetime.datetime``
8585
"""
86-
# We use udatetime since it's much faster than non-C alternatives
86+
# We use ciso8601 since it's much faster than non-C alternatives
8787
# For compatibility reasons we still fall back to datetutil, but this should rarely happen
8888
# rfc3339 covers 90% of the iso8601 (it's a subset of it)
8989
original_value = value
9090

9191
try:
92-
if " " in value:
93-
# udatetime doesn't support notation with whitespace so we replace it with T
94-
value = value.replace(" ", "T")
95-
dt = udatetime.from_string(str(value))
92+
dt = ciso8601.parse_datetime(str(value))
9693
except Exception:
9794
dt = dateutil.parser.parse(str(original_value))
9895

0 commit comments

Comments
 (0)