CREATE SCHEMA IF NOT EXISTS `util`;
USE `util`;

DELIMITER ;;
DROP FUNCTION IF EXISTS `util`.`mockedDate`;
CREATE FUNCTION `util`.`mockedDate`()
RETURNS DATETIME
DETERMINISTIC
BEGIN
    RETURN CONVERT_TZ('2001-01-01 11:00:00', 'utc', 'Europe/Madrid');
END ;;
DELIMITER ;

DELIMITER ;;
DROP FUNCTION IF EXISTS `util`.`VN_CURDATE`;
CREATE FUNCTION `util`.`VN_CURDATE`()
RETURNS DATE
DETERMINISTIC
BEGIN
    RETURN DATE(mockedDate());
END ;;
DELIMITER ;

DELIMITER ;;
DROP FUNCTION IF EXISTS `util`.`VN_CURTIME`;
CREATE FUNCTION `util`.`VN_CURTIME`()
RETURNS TIME
DETERMINISTIC
BEGIN
    RETURN TIME(mockedDate());
END ;;
DELIMITER ;

DELIMITER ;;
DROP FUNCTION IF EXISTS `util`.`VN_NOW`;
CREATE FUNCTION `util`.`VN_NOW`()
RETURNS DATETIME
DETERMINISTIC
BEGIN
    RETURN mockedDate();
END ;;
DELIMITER ;
