Skip to content

Commit c54def2

Browse files
committed
Update date metadata logic to include timezone information
Modified the handling of creation and updated dates to ensure that the datetime objects are timezone-aware by replacing the timezone info with UTC. This change improves the accuracy of date metadata in the rules.
1 parent 23167a0 commit c54def2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

detection_rules/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,10 @@ def import_rules_into_repo( # noqa: PLR0912, PLR0913, PLR0915
258258
now = datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%S.%fZ")
259259
contents["creation_date"] = datetime.strptime(
260260
contents.get("created_at", now), "%Y-%m-%dT%H:%M:%S.%fZ"
261-
).strftime("%Y/%m/%d")
261+
).replace(tzinfo=UTC).strftime("%Y/%m/%d")
262262
contents["updated_date"] = datetime.strptime(
263263
contents.get("updated_at", now), "%Y-%m-%dT%H:%M:%S.%fZ"
264-
).strftime("%Y/%m/%d")
264+
).replace(tzinfo=UTC).strftime("%Y/%m/%d")
265265

266266
contents.update(
267267
update_metadata_from_file(

0 commit comments

Comments
 (0)