mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Beta: Fix Timezone issues
This commit is contained in:
@@ -31,6 +31,7 @@ COPY . /home/pi/pialert
|
||||
# Pi.Alert
|
||||
RUN python /home/pi/pialert/back/pialert.py update_vendors \
|
||||
&& sed -ie 's/= 80/= '${PORT}'/g' /etc/lighttpd/lighttpd.conf \
|
||||
&& sed -i.bak 's/^\(TIMEZONE=\).*/\'${TZ}'/' /home/pi/pialert/config/pialert.conf \
|
||||
&& (crontab -l 2>/dev/null; cat /home/pi/pialert/install/pialert.cron) | crontab -
|
||||
|
||||
# it's easy for permissions set in Git to be overridden, so doing it manually
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
VERSION = '3.5_leiweibau'
|
||||
VERSION_YEAR = '2022'
|
||||
VERSION_DATE = '2022-07-07'
|
||||
TZ = 'Europe/London'
|
||||
VERSION_DATE = '2022-07-07'
|
||||
@@ -8,6 +8,13 @@
|
||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// ## TimeZone processing
|
||||
$config_file = "../config/pialert.conf";
|
||||
$config_file_lines = file($config_file);
|
||||
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
||||
$timezone_line = explode("'", $config_file_lines_timezone[0]);
|
||||
$Pia_TimeZone = $timezone_line[1];
|
||||
date_default_timezone_set($Pia_TimeZone);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// DB File Path
|
||||
@@ -58,4 +65,4 @@ function OpenDB () {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -116,8 +116,10 @@ function getDeviceData() {
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$deviceData['dev_DownAlerts'] = $row[0];
|
||||
|
||||
// Get current date using php, sql datetime does not return time respective to timezone.
|
||||
$currentdate = date("Y-m-d H:i:s");
|
||||
// Presence hours
|
||||
$sql = 'SELECT CAST(( MAX (0, SUM (julianday (IFNULL (ses_DateTimeDisconnection, DATETIME("now","localtime")))
|
||||
$sql = 'SELECT CAST(( MAX (0, SUM (julianday (IFNULL (ses_DateTimeDisconnection,"'. $currentdate .'" ))
|
||||
- julianday (CASE WHEN ses_DateTimeConnection < '. $periodDate .' THEN '. $periodDate .'
|
||||
ELSE ses_DateTimeConnection END)) *24 )) AS INT)
|
||||
FROM Sessions
|
||||
|
||||
@@ -275,7 +275,7 @@ function getDevicePresence() {
|
||||
END AS ses_DateTimeConnectionCorrected,
|
||||
|
||||
CASE
|
||||
WHEN ses_EventTypeDisconnection = "<missing event>" THEN
|
||||
WHEN ses_EventTypeDisconnection = "<missing event>" OR ses_EventTypeDisconnection = NULL THEN
|
||||
(SELECT MIN(ses_DateTimeConnection) FROM Sessions AS SES2 WHERE SES2.ses_MAC = SES1.ses_MAC AND SES2.ses_DateTimeConnection > SES1.ses_DateTimeConnection)
|
||||
ELSE ses_DateTimeDisconnection
|
||||
END AS ses_DateTimeDisconnectionCorrected
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
// Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// ## TimeZone processing
|
||||
$config_file = "../config/pialert.conf";
|
||||
$config_file_lines = file($config_file);
|
||||
$config_file_lines_timezone = array_values(preg_grep('/^TIMEZONE\s.*/', $config_file_lines));
|
||||
$timezone_line = explode("'", $config_file_lines_timezone[0]);
|
||||
$Pia_TimeZone = $timezone_line[1];
|
||||
date_default_timezone_set($Pia_TimeZone);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Formatting data functions
|
||||
|
||||
Reference in New Issue
Block a user