mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-15 22:51:37 -07:00
fixes
This commit is contained in:
+1
-1
@@ -464,7 +464,7 @@ function localizeTimestamp(input) {
|
||||
if (!hasOffset) {
|
||||
// Ensure proper ISO format before appending Z
|
||||
// Replace space with 'T' if needed: "2026-02-11 11:37:02" → "2026-02-11T11:37:02Z"
|
||||
isoStr = isoStr.replace(' ', 'T') + 'Z';
|
||||
isoStr = isoStr.trim().replace(/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})$/, '$1T$2') + 'Z';
|
||||
}
|
||||
|
||||
const date = new Date(isoStr);
|
||||
|
||||
@@ -93,7 +93,7 @@ class EventInstance:
|
||||
eve_EventType, eve_AdditionalInfo,
|
||||
eve_PendingAlertEmail, eve_PairEventRowid
|
||||
) VALUES (?,?,?,?,?,?,?)
|
||||
""", (mac, ip, timeNowUTC(as_string=False), eventType, info,
|
||||
""", (mac, ip, timeNowUTC(), eventType, info,
|
||||
1 if pendingAlert else 0, pairRow))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
@@ -48,8 +48,11 @@ def timeNowUTC(as_string=True):
|
||||
|
||||
|
||||
def get_timezone_offset():
|
||||
now = timeNowUTC(as_string=False).replace(tzinfo=conf.tz) if conf.tz else timeNowUTC(as_string=False)
|
||||
offset_hours = now.utcoffset().total_seconds() / 3600 if now.utcoffset() else 0
|
||||
if conf.tz:
|
||||
now = timeNowUTC(as_string=False).astimezone(conf.tz)
|
||||
offset_hours = now.utcoffset().total_seconds() / 3600
|
||||
else:
|
||||
offset_hours = 0
|
||||
offset_formatted = "{:+03d}:{:02d}".format(int(offset_hours), int((offset_hours % 1) * 60))
|
||||
return offset_formatted
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ def test_get_sessions_calendar(client, api_token, test_mac):
|
||||
Cleans up test sessions after test.
|
||||
"""
|
||||
# --- Setup: create two sessions for the test MAC ---
|
||||
now = datetime.now()
|
||||
now = timeNowUTC(as_string=False)
|
||||
start1 = (now - timedelta(days=2)).isoformat(timespec="seconds")
|
||||
end1 = (now - timedelta(days=1, hours=20)).isoformat(timespec="seconds")
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class TestTimeNowUTC:
|
||||
def test_timeNowUTC_datetime_has_UTC_timezone(self):
|
||||
"""Test that datetime object has UTC timezone"""
|
||||
result = timeNowUTC(as_string=False)
|
||||
assert result.tzinfo is datetime.UTC or result.tzinfo is not None
|
||||
assert result.tzinfo is datetime.UTC
|
||||
|
||||
def test_timeNowUTC_datetime_no_microseconds(self):
|
||||
"""Test that datetime object has microseconds set to 0"""
|
||||
|
||||
Reference in New Issue
Block a user