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