Skip to content

Commit

Permalink
Use only date in datetime comparison
Browse files Browse the repository at this point in the history
Signed-off-by: Caroline Russell <caroline@appthreat.dev>
  • Loading branch information
cerrussell committed Aug 5, 2024
1 parent 6e09cc3 commit a8ee590
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions custom_json_diff/custom_diff_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,11 @@ def compare_bom_refs(v1: str, v2: str) -> bool:

def compare_date(dt1: str, dt2: str, comparator: str):
"""Compares two dates"""
if dt1 == dt2 or (not dt1 and not dt2):
if not dt1 and not dt2:
return True
try:
date_1 = datetime.fromisoformat(dt1)
date_2 = datetime.fromisoformat(dt2)
date_1 = datetime.fromisoformat(dt1).date()
date_2 = datetime.fromisoformat(dt2).date()
match comparator:
case "<":
return date_1 < date_2
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "custom-json-diff"
version = "1.5.5"
version = "1.5.6"
description = "Custom JSON and CycloneDx BOM diffing and comparison tool."
authors = [
{ name = "Caroline Russell", email = "caroline@appthreat.dev" },
Expand Down

0 comments on commit a8ee590

Please sign in to comment.