78 lines
1.9 KiB
PHP
78 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace mt;
|
|
|
|
use phpcommon;
|
|
|
|
class HashRateCommon {
|
|
|
|
public static function find($id){
|
|
return getXVal(self::getMetaList(), $id, null);
|
|
}
|
|
|
|
public static function getLatestPeriod(){
|
|
$period = self::getMetaList() ? self::getMetaList()[1] : array();
|
|
foreach (self::getMetaList() as $key => $meta) {
|
|
if (myself()->_getNowTime() >= strtotime($meta['end_time'])) {
|
|
$period = $meta;
|
|
}
|
|
}
|
|
return $period;
|
|
}
|
|
|
|
public static function checkAwaitTime(){
|
|
$period = self::getLatestPeriod();
|
|
// print_r(myself()->_getNowTime() . "======". strtotime($period['end_time']));
|
|
if ($period && myself()->_getNowTime() > strtotime($period['end_time'])){
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static function getCurrentPeriod()
|
|
{
|
|
foreach (self::getMetaList() as $meta) {
|
|
if (myself()->_getNowTime() >= strtotime($meta['start_time']) &&
|
|
myself()->_getNowTime() <= strtotime($meta['end_time'])) {
|
|
return $meta;
|
|
}
|
|
}
|
|
return array();
|
|
}
|
|
|
|
public static function getNextPeriod()
|
|
{
|
|
$next = array();
|
|
foreach (self::getMetaList() as $meta){
|
|
if (myself()->_getNowTime() < strtotime($meta['start_time'])){
|
|
$next = $meta;
|
|
break;
|
|
}
|
|
}
|
|
return $next;
|
|
}
|
|
|
|
public static function getLastPeriod()
|
|
{
|
|
$last = array();
|
|
foreach (self::getMetaList() as $meta){
|
|
if (myself()->_getNowTime() > strtotime($meta['end_time'])){
|
|
$last = $meta;
|
|
}
|
|
}
|
|
return $last;
|
|
}
|
|
|
|
|
|
protected static function getMetaList()
|
|
{
|
|
if (!self::$metaList) {
|
|
self::$metaList = getMetaTable('HashrateCommon@HashrateCommon.php');
|
|
}
|
|
return self::$metaList;
|
|
}
|
|
|
|
protected static $metaList;
|
|
|
|
}
|