/* ** Zabbix ** Copyright (C) 2001-2024 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. **/ #include "common.h" static void tm_add(struct tm *tm, int multiplier, zbx_time_unit_t base); static void tm_sub(struct tm *tm, int multiplier, zbx_time_unit_t base); static int time_unit_seconds[ZBX_TIME_UNIT_COUNT] = {0, 1, SEC_PER_MIN, SEC_PER_HOUR, SEC_PER_DAY, SEC_PER_WEEK, 0, 0, 0}; zbx_time_unit_t zbx_tm_str_to_unit(const char *text) { switch (*text) { case 's': return ZBX_TIME_UNIT_SECOND; case 'm': return ZBX_TIME_UNIT_MINUTE; case 'h': return ZBX_TIME_UNIT_HOUR; case 'd': return ZBX_TIME_UNIT_DAY; case 'w': return ZBX_TIME_UNIT_WEEK; case 'M': return ZBX_TIME_UNIT_MONTH; case 'y': return ZBX_TIME_UNIT_YEAR; default: return ZBX_TIME_UNIT_UNKNOWN; } } /****************************************************************************** * * * Purpose: parse time period in format