<?php

/**
 * Created by PhpStorm.
 * User: stanley-king
 * Date: 2017/5/25
 * Time: 上午10:21
 */

define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
require_once(BASE_ROOT_PATH . '/fooder.php');
require_once(BASE_ROOT_PATH . '/helper/stat_helper.php');
require_once(BASE_ROOT_PATH . '/helper/stat_helper.php');
require_once(BASE_ROOT_PATH . '/helper/util_helper.php');

class TestTime extends PHPUnit_Framework_TestCase
{
    public static function setUpBeforeClass()
    {
        Base::run_util();
    }

    public function testS()
    {
        $tm = strtotime('2017-08-01 3:43:00');
        $tm1 = strtotime('2017-8-01 3:43:00');
        $tm2 = strtotime('2017-08-1 3:43:00');
        $tm3 = strtotime('2017-8-1 3:43:00');

        $tm3 = strtotime('2017-8-1 03:43:00');
        $tm3 = strtotime('2017-8-1 3:43:00');
        $tm3 = strtotime('2017-8-1  3:43');
    }
    public function testDay()
    {
        $date = date('Y-m-d',time());
        $this->mStartm = strtotime(date('Y-m-d',time()));
        $this->mEndtm  = $this->mStartm + 86400 - 1;
    }

    public function testWeek()
    {
        $date = date('Y-m-d',time());
        $cur_time = strtotime(date('Y-m-d',time())) + 86400;
        $start = $cur_time - 86400 * 7;
        $end = $cur_time -1;

        $v = ($end - $start + 1) / 86400;
    }

    public function testMonth()
    {
        $cur = time();
        $cur_date = new DateTime();
        $cur_date->setTimestamp($cur);
        $inter = new DateInterval('P1M');
        $cur_date->sub($inter);
        $time = $cur_date->getTimestamp();
    }

    public function testLastsec()
    {
        $expried_secs = 10 * 24 * 3600;
        $usable_time = time() + $expried_secs;
        $cur_date = date('Y-m-d H:i:s',$usable_time);
        $cur_time = strtotime(date('Y-m-d',$usable_time)) + 86399;
        $curx_date = date('Y-m-d H:i:s',$cur_time);

        $cur_time = util::last_day_secs($usable_time);
        $cury_date = date('Y-m-d H:i:s',$cur_time);


        $delta = $usable_time - $cur_time;
    }

    public function testMtrand()
    {
        for ($i = 0; $i < 100; $i++) {
            echo mt_rand(0,6);
            echo "\n";
        }
    }

}
