<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; class TimeUtil { const FORMAT_DATE = 'Y-m-d'; const FORMAT_DATETIME = 'Y-m-d H:i:s'; const PERIOD_YEAR = 24 * 3600 * 365; const PERIOD_MONTH = 24 * 3600 * 30; const PERIOD_WEEK = 24 * 3600 * 7; const PERIOD_DAY = 24 * 3600; const PERIOD_HOUR = 3600; const PERIOD_MINITE = 60; const MINUTE_PERIOD_YEAR = 24 * 60 * 365; const MINUTE_PERIOD_MONTH = 24 * 60 * 30; const MINUTE_PERIOD_WEEK = 24 * 60 * 7; const MINUTE_PERIOD_DAY = 24 * 60; const MINUTE_PERIOD_HOUR = 60; const MINUTE_PERIOD_MINITE = 1; public static function humanTimeLength($O59SE, $BwT23 = 'zh') { goto rRJjQ; XegNn: if ($O59SE > 0) { $jn7xf[] = $O59SE . $yzvYf[$BwT23]['s']; } goto aUa38; aUa38: return join('', $jn7xf); goto RR4R7; rRJjQ: $yzvYf = array('zh' => array('d' => '天', 'h' => '小时', 'm' => '分钟', 's' => '秒'), 'en' => array('d' => 'd', 'h' => 'h', 'm' => 'm', 's' => 's')); goto cFOw3; OSTt2: if ($O59SE >= self::PERIOD_HOUR) { goto FxKK9; FxKK9: $ohYVl = intval($O59SE / self::PERIOD_HOUR); goto eQIxH; eQIxH: $jn7xf[] = $ohYVl . $yzvYf[$BwT23]['h']; goto CJgtp; CJgtp: $O59SE %= self::PERIOD_HOUR; goto GMy7S; GMy7S: } goto UyjAx; bVnuE: if ($O59SE >= self::PERIOD_DAY) { goto DQt3h; DQt3h: $ohYVl = intval($O59SE / self::PERIOD_DAY); goto XMN40; XMN40: $jn7xf[] = $ohYVl . $yzvYf[$BwT23]['d']; goto lg3oz; lg3oz: $O59SE %= self::PERIOD_DAY; goto bljTX; bljTX: } goto OSTt2; UyjAx: if ($O59SE >= self::PERIOD_MINITE) { goto bioxg; bioxg: $ohYVl = intval($O59SE / self::PERIOD_MINITE); goto HyN6m; TBZBj: $O59SE %= self::PERIOD_MINITE; goto w3xG3; HyN6m: $jn7xf[] = $ohYVl . $yzvYf[$BwT23]['m']; goto TBZBj; w3xG3: } goto XegNn; cFOw3: $jn7xf = array(); goto bVnuE; RR4R7: } public static function date() { return date(self::FORMAT_DATE, time()); } public static function now() { return date(self::FORMAT_DATETIME, time()); } public static function format($PVm_Y, $FpVuW = null) { if (null === $FpVuW) { $FpVuW = self::FORMAT_DATETIME; } return date($FpVuW, $PVm_Y); } public static function isBefore($PVm_Y, $RvYDg) { return $PVm_Y < time() - $RvYDg; } public static function getBeforeTimestamp($RvYDg) { return time() - $RvYDg; } public static function getBeforeDatetime($RvYDg) { return date(self::FORMAT_DATETIME, self::getBeforeTimestamp($RvYDg)); } public static function isDatetimeEmpty($PI6ZB) { goto dlzN2; yF1On: if (empty($PVm_Y) || $PVm_Y < 0) { return true; } goto e9U3V; e9U3V: return false; goto IDDNv; dlzN2: $PVm_Y = strtotime($PI6ZB); goto yF1On; IDDNv: } public static function isDateEmpty($bumbz) { goto aYQEz; aYQEz: $PVm_Y = strtotime($bumbz); goto EWzqp; pvVP7: return false; goto gW4XB; EWzqp: if (empty($PVm_Y) || $PVm_Y < 0) { return true; } goto pvVP7; gW4XB: } public static function isTimeEmpty($XvAnK) { goto Z_ZZF; KeFfV: return false; goto VRRtE; Z5GyN: if (empty($PVm_Y) || $PVm_Y < 0) { return true; } goto KeFfV; Z_ZZF: $PVm_Y = strtotime('2019-01-01 ' . $XvAnK); goto Z5GyN; VRRtE: } public static function isDateExpired($FJAM8) { goto Ry0U5; fnAWm: return false; goto ee6W9; rmbkN: if (strtotime($FJAM8) < time()) { return true; } goto fnAWm; Ry0U5: if (self::isDateEmpty($FJAM8)) { return false; } goto rmbkN; ee6W9: } public static function nextExpireTimestamp($ZJxPK, $diTIb, $FpVuW = 'Y-m-d') { goto Ikfbv; FPjz3: if (!empty($ZJxPK) && $K3Ni_ > 0) { $ILXZ3 = $K3Ni_ + $diTIb; } else { $ILXZ3 += $diTIb; } goto ofYlI; Ikfbv: $ILXZ3 = time(); goto JedYe; ofYlI: return date($FpVuW, $ILXZ3); goto am5lK; JedYe: $K3Ni_ = strtotime($ZJxPK); goto FPjz3; am5lK: } public static function isInRange($VEnMw, $XoefR) { goto n4vgl; xTHXg: if (!self::isDatetimeEmpty($XoefR)) { $XoefR = strtotime($XoefR); if ($ILXZ3 > $XoefR) { return false; } } goto hBWbo; n4vgl: $ILXZ3 = time(); goto OnaCq; hBWbo: return true; goto rMWsl; OnaCq: if (!self::isDatetimeEmpty($VEnMw)) { $VEnMw = strtotime($VEnMw); if ($ILXZ3 < $VEnMw) { return false; } } goto xTHXg; rMWsl: } }