ovpnclients.dat: Fix adjusting input dates

This patch changes that we no longer interpret any dates put in by the
user as UTC. They used to be converted into localtime because, although
they have already been in local time.

This went unnoticed since in Europe we are close (enough) to UTC that
there is no significant discrepancy on the report. However, being in
North America is enough to generate confusing reports.

Reported-by: Paul <kairis@gmail.com>
Fixes: #12768
Tested-by: Jon Murphy <jon.murphy@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2022-02-15 13:40:27 +00:00
committed by Peter Müller
parent bccde9948b
commit 6e40963459

View File

@@ -115,16 +115,16 @@ my $database_query = qq(
common_name, SUM(
STRFTIME('%s', (
CASE
WHEN DATETIME(COALESCE(disconnected_at, CURRENT_TIMESTAMP), 'localtime') < DATETIME('$to_datestring', 'localtime', 'start of day', '+86399 seconds')
WHEN DATETIME(COALESCE(disconnected_at, CURRENT_TIMESTAMP), 'localtime') < DATETIME('$to_datestring', 'start of day', '+86399 seconds')
THEN DATETIME(COALESCE(disconnected_at, CURRENT_TIMESTAMP), 'localtime')
ELSE DATETIME('$to_datestring', 'localtime', 'start of day', '+86399 seconds')
ELSE DATETIME('$to_datestring', 'start of day', '+86399 seconds')
END
), 'utc') -
STRFTIME('%s', (
CASE
WHEN DATETIME(connected_at, 'localtime') > DATETIME('$from_datestring', 'localtime', 'start of day')
WHEN DATETIME(connected_at, 'localtime') > DATETIME('$from_datestring', 'start of day')
THEN DATETIME(connected_at, 'localtime')
ELSE DATETIME('$from_datestring', 'localtime', 'start of day')
ELSE DATETIME('$from_datestring', 'start of day')
END
), 'utc')
) AS duration
@@ -133,10 +133,10 @@ my $database_query = qq(
(
disconnected_at IS NULL
OR
DATETIME(disconnected_at, 'localtime') > DATETIME('$from_datestring', 'localtime', 'start of day')
DATETIME(disconnected_at, 'localtime') > DATETIME('$from_datestring', 'start of day')
)
AND
DATETIME(connected_at, 'localtime') < DATETIME('$to_datestring', 'localtime', 'start of day', '+86399 seconds')
DATETIME(connected_at, 'localtime') < DATETIME('$to_datestring', 'start of day', '+86399 seconds')
GROUP BY common_name
ORDER BY common_name, duration DESC;
);
@@ -148,9 +148,9 @@ if ($cgiparams{'CONNECTION_NAME'}) {
WHERE
common_name = '$cgiparams{"CONNECTION_NAME"}'
AND (
DATETIME(disconnected_at, 'localtime') > DATETIME('$from_datestring', 'localtime', 'start of day')
DATETIME(disconnected_at, 'localtime') > DATETIME('$from_datestring', 'start of day')
AND
DATETIME(connected_at, 'localtime') < DATETIME('$to_datestring', 'localtime', 'start of day', '+86399 seconds')
DATETIME(connected_at, 'localtime') < DATETIME('$to_datestring', 'start of day', '+86399 seconds')
)
ORDER BY connected_at;
);