salix/db/routines/util/functions/mockTimeBase.sql

27 lines
604 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`mockTimeBase`(vIsUtc BOOL)
RETURNS datetime
DETERMINISTIC
BEGIN
/**
* Returns the date formatted to utc if vIsUtc or config.mocTz if not
*
* @param vIsUtc If date must be returned as UTC format
* @return The formatted mock time
*/
DECLARE vMockUtcTime DATETIME;
DECLARE vMockTz VARCHAR(255);
SELECT mockUtcTime, mockTz
INTO vMockUtcTime, vMockTz
FROM config
LIMIT 1;
IF vIsUtc OR vMockTz IS NULL THEN
RETURN vMockUtcTime;
ELSE
RETURN CONVERT_TZ(vMockUtcTime, '+00:00', vMockTz);
END IF;
END$$
DELIMITER ;