Skip to content

Commit 09f2160

Browse files
authored
Update ms_intune_apple_vpp_tokens.py
Set the datetime timezone from None to UTC so that the time difference is calculated correctly.
1 parent 3b4bfeb commit 09f2160

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

intune/agent_based/ms_intune_apple_vpp_tokens.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import json
2222
from collections.abc import Mapping, Sequence
2323
from dataclasses import dataclass
24-
from datetime import datetime
24+
from datetime import datetime, timezone
2525
from typing import Any
2626

2727
from cmk.agent_based.v2 import (
@@ -90,18 +90,18 @@ def check_ms_intune_apple_vpp_tokens(item: str, params: Mapping[str, Any], secti
9090
token_state = token["token_state"]
9191
token_expiration = token["token_expiration"]
9292

93-
token_expiration_datetime = datetime.strptime(token_expiration, "%Y-%m-%dT%H:%M:%SZ")
94-
token_expiration_timestamp = token_expiration_datetime.timestamp()
93+
token_expiration_datetime_utc = datetime.strptime(token_expiration, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=timezone.utc)
94+
token_expiration_timestamp = token_expiration_datetime_utc.timestamp()
9595
token_expiration_timestamp_render = render.datetime(int(token_expiration_timestamp))
9696

9797
token_expiration_timespan = token_expiration_timestamp - datetime.now().timestamp()
9898

9999
result_details = (
100-
f"Expiration time: {token_expiration_timestamp_render} (UTC)"
100+
f"Expiration time: {token_expiration_timestamp_render}"
101101
f"\\nState: {token_state}"
102102
f"\\nApple ID: {token_appleid}"
103103
)
104-
result_summary = f"Expiration time: {token_expiration_timestamp_render} (UTC), State: {token_state}"
104+
result_summary = f"Expiration time: {token_expiration_timestamp_render}, State: {token_state}"
105105

106106
if token_expiration_timespan > 0:
107107
yield from check_levels(

0 commit comments

Comments
 (0)