<?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 formatTimeLength($lMemx) { goto mcGRq; ociqj: return date('H:i:s', $JKZ5M + $lMemx); goto SsgRX; oSfeh: if (null === $JKZ5M) { $JKZ5M = strtotime('2020-01-01 00:00:00'); } goto ociqj; mcGRq: static $JKZ5M = null; goto oSfeh; SsgRX: } public static function yesterdayDate() { return date('Y-m-d', time() - self::PERIOD_DAY); } public static function yesterdayStart() { return date('Y-m-d 00:00:00', time() - self::PERIOD_DAY); } public static function yesterdayEnd() { return date('Y-m-d 23:59:59', time() - self::PERIOD_DAY); } public static function humanTimeLength($iW2nT, $smkie = 'zh') { goto Yje63; Qp3Wv: if ($iW2nT >= self::PERIOD_MINITE) { goto j88z9; j88z9: $tHq0l = intval($iW2nT / self::PERIOD_MINITE); goto PM4Dw; vD2FI: $iW2nT %= self::PERIOD_MINITE; goto dMiyf; PM4Dw: $jT5GX[] = $tHq0l . $qhEcn[$smkie]['m']; goto vD2FI; dMiyf: } goto RKI5b; RKI5b: if ($iW2nT > 0) { $jT5GX[] = $iW2nT . $qhEcn[$smkie]['s']; } goto cBPgT; ShFN1: if ($iW2nT >= self::PERIOD_DAY) { goto MQl20; HEP4t: $iW2nT %= self::PERIOD_DAY; goto gpHdN; b7K67: $jT5GX[] = $tHq0l . $qhEcn[$smkie]['d']; goto HEP4t; MQl20: $tHq0l = intval($iW2nT / self::PERIOD_DAY); goto b7K67; gpHdN: } goto R0xhC; Yje63: $qhEcn = array('zh' => array('d' => '天', 'h' => '小时', 'm' => '分钟', 's' => '秒'), 'en' => array('d' => 'd', 'h' => 'h', 'm' => 'm', 's' => 's')); goto MhhiX; R0xhC: if ($iW2nT >= self::PERIOD_HOUR) { goto Cw4Mf; gvNi5: $iW2nT %= self::PERIOD_HOUR; goto Ao5p3; Cw4Mf: $tHq0l = intval($iW2nT / self::PERIOD_HOUR); goto sPygS; sPygS: $jT5GX[] = $tHq0l . $qhEcn[$smkie]['h']; goto gvNi5; Ao5p3: } goto Qp3Wv; cBPgT: return join('', $jT5GX); goto zbMvg; MhhiX: $jT5GX = array(); goto ShFN1; zbMvg: } public static function date() { return date(self::FORMAT_DATE, time()); } public static function now() { return date(self::FORMAT_DATETIME, time()); } public static function format($tfKvy, $UeI_l = null) { if (null === $UeI_l) { $UeI_l = self::FORMAT_DATETIME; } return date($UeI_l, $tfKvy); } public static function isBefore($tfKvy, $g7DGD) { return $tfKvy < time() - $g7DGD; } public static function getBeforeTimestamp($g7DGD) { return time() - $g7DGD; } public static function getBeforeDatetime($g7DGD) { return date(self::FORMAT_DATETIME, self::getBeforeTimestamp($g7DGD)); } public static function isDatetimeEmpty($qDQ4k) { goto euJ8G; euJ8G: $tfKvy = strtotime($qDQ4k); goto G5olu; G5olu: if (empty($tfKvy) || $tfKvy < 0) { return true; } goto vpXfp; vpXfp: return false; goto gPkqN; gPkqN: } public static function isDateEmpty($RWS7w) { goto oTQqk; iLzYP: return false; goto rI5FP; oTQqk: $tfKvy = strtotime($RWS7w); goto CQLrJ; CQLrJ: if (empty($tfKvy) || $tfKvy < 0) { return true; } goto iLzYP; rI5FP: } public static function isTimeEmpty($gmNPm) { goto sRK2I; sRK2I: $tfKvy = strtotime('2019-01-01 ' . $gmNPm); goto vStJ2; vStJ2: if (empty($tfKvy) || $tfKvy < 0) { return true; } goto zyEi7; zyEi7: return false; goto z7cgV; z7cgV: } public static function isDateExpired($Mujjm) { goto Hm3CI; im91l: return false; goto YO736; Hm3CI: if (self::isDateEmpty($Mujjm)) { return false; } goto RBDrw; RBDrw: if (strtotime($Mujjm) < time()) { return true; } goto im91l; YO736: } public static function nextExpireTimestamp($rskFA, $qjNOR, $UeI_l = 'Y-m-d') { goto lu__5; lu__5: $JKZ5M = time(); goto QUXPD; hSGfx: return date($UeI_l, $JKZ5M); goto c6QoX; MmFjo: if (!empty($rskFA) && $eQWJY > 0) { $JKZ5M = $eQWJY + $qjNOR; } else { $JKZ5M += $qjNOR; } goto hSGfx; QUXPD: $eQWJY = strtotime($rskFA); goto MmFjo; c6QoX: } public static function isInRange($mTKI1, $ineBL) { goto bDjs8; wc_4c: if (!self::isDatetimeEmpty($ineBL)) { $ineBL = strtotime($ineBL); if ($JKZ5M > $ineBL) { return false; } } goto YUr1Q; bDjs8: $JKZ5M = time(); goto MA6sc; YUr1Q: return true; goto Bd9mh; MA6sc: if (!self::isDatetimeEmpty($mTKI1)) { $mTKI1 = strtotime($mTKI1); if ($JKZ5M < $mTKI1) { return false; } } goto wc_4c; Bd9mh: } public static function periodToSecond($g7DGD) { goto IJiJO; F9lKt: if (isset($jT5GX[2])) { $lMemx += intval($jT5GX[1]); } goto cAt_E; cAt_E: return $lMemx; goto ESV5V; cjoCU: if (isset($jT5GX[1])) { $lMemx += intval($jT5GX[1]) * 60; } goto F9lKt; Q70GP: $jT5GX = explode(':', $g7DGD); goto w2WTw; IJiJO: $lMemx = 0; goto Q70GP; w2WTw: if (isset($jT5GX[0])) { $lMemx += intval($jT5GX[0]) * 3600; } goto cjoCU; ESV5V: } }