2020-12-22 19:23:08 +08:00

64 lines
1.3 KiB
PHP

<?php
namespace metatable;
use phpcommon;
/*
配置表规范
getXXXConf:获取表所有数据
getXxxById():通过id获取单个数据
_internalGetXXXConf:获取表所有数据内部实现不对外开放
使用方式
require_once 'metatable/XXXX.php';
!!!注意必须使用require_once
*/
function getSeasonConf()
{
return _internalGetSeasonConf();
}
function getSeasonById($sea_id)
{
$conf = getSeasonConf();
$sea_id = (int)$sea_id;
return array_key_exists($sea_id, $conf) ? $conf[$sea_id] : null;
}
function _internalGetSeasonConf()
{
global $g_sea_table;
if (!$g_sea_table) {
$g_sea_table = require(getConfigBaseDir() . 'season@season.php');
}
return $g_sea_table;
}
function getNowSeason()
{
$conf = getSeasonConf();
for ($i = 1; $i <= count($conf); $i++) {
$sea = getSeasonById($i);
if (phpcommon\getNowTime() >= strtotime($sea['time1']) && phpcommon\getNowTime() <= strtotime($sea['time2'])) {
return $sea;
}
}
return null;
}
function getNowSeasonNum()
{
$conf = getSeasonConf();
for ($i = 1; $i <= count($conf); $i++) {
$sea = getSeasonById($i);
if (phpcommon\getNowTime() >= strtotime($sea['time1']) && phpcommon\getNowTime() <= strtotime($sea['time2'])) {
return $i;
}
}
return null;
}