Source
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
function timeperiod_type2str($timeperiod_type) {
switch ($timeperiod_type) {
case TIMEPERIOD_TYPE_ONETIME:
return _('One time only');
case TIMEPERIOD_TYPE_DAILY:
return _('Daily');
case TIMEPERIOD_TYPE_WEEKLY:
return _('Weekly');
case TIMEPERIOD_TYPE_MONTHLY:
return _('Monthly');
}
return _('Unknown');
}
function schedule2str($timeperiod) {
$timeperiod['hour'] = floor($timeperiod['start_time'] / SEC_PER_HOUR);
$timeperiod['minute'] = floor(($timeperiod['start_time'] - ($timeperiod['hour'] * SEC_PER_HOUR)) / SEC_PER_MIN);
if ($timeperiod['hour'] < 10) {
$timeperiod['hour'] = '0'.$timeperiod['hour'];
}
if ($timeperiod['minute'] < 10) {
$timeperiod['minute'] = '0'.$timeperiod['minute'];
}
if ($timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_ONETIME) {
$str = zbx_date2str(DATE_TIME_FORMAT, $timeperiod['start_date']);
}
elseif ($timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_DAILY) {
$str = _n('At %1$s:%2$s every day',
'At %1$s:%2$s every %3$s days',
$timeperiod['hour'],
$timeperiod['minute'],
$timeperiod['every']
);
}
elseif ($timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_WEEKLY) {
$days = '';
$dayofweek = zbx_num2bitstr($timeperiod['dayofweek'], true);
$length = strlen($dayofweek);
for ($i = 0; $i < $length; $i++) {
if ($dayofweek[$i] == 1) {
if (!zbx_empty($days)) {