Skip to content

Commit b08802e

Browse files
author
Michael Brewer
committed
fix(dataclasses): include milliseconds in scalar types
1 parent cc128ad commit b08802e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: aws_lambda_powertools/utilities/data_classes/appsync/scalar_types_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def aws_time(timezone_offset: int = 0) -> str:
6565
str
6666
Returns current time as AWSTime scalar string with optional timezone offset
6767
"""
68-
return _formatted_time(datetime.datetime.utcnow(), "%H:%M:%S", timezone_offset)
68+
return _formatted_time(datetime.datetime.utcnow(), "%H:%M:%S.%f", timezone_offset)
6969

7070

7171
def aws_datetime(timezone_offset: int = 0) -> str:
@@ -81,7 +81,7 @@ def aws_datetime(timezone_offset: int = 0) -> str:
8181
str
8282
Returns current time as AWSDateTime scalar string with optional timezone offset
8383
"""
84-
return _formatted_time(datetime.datetime.utcnow(), "%Y-%m-%dT%H:%M:%S", timezone_offset)
84+
return _formatted_time(datetime.datetime.utcnow(), "%Y-%m-%dT%H:%M:%S.%f", timezone_offset)
8585

8686

8787
def aws_timestamp() -> int:

Diff for: tests/functional/test_data_classes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1210,13 +1210,13 @@ def test_aws_date_utc():
12101210
def test_aws_time_utc():
12111211
time_str = aws_time()
12121212
assert isinstance(time_str, str)
1213-
assert datetime.datetime.strptime(time_str, "%H:%M:%SZ")
1213+
assert datetime.datetime.strptime(time_str, "%H:%M:%S.%fZ")
12141214

12151215

12161216
def test_aws_datetime_utc():
12171217
datetime_str = aws_datetime()
12181218
assert isinstance(datetime_str, str)
1219-
assert datetime.datetime.strptime(datetime_str, "%Y-%m-%dT%H:%M:%SZ")
1219+
assert datetime.datetime.strptime(datetime_str, "%Y-%m-%dT%H:%M:%S.%fZ")
12201220

12211221

12221222
def test_aws_timestamp():

0 commit comments

Comments
 (0)