This method is intend to return the current week.

@param mixed $timestamp The timestamp to use as date/time-base

@author Benjamin Carl <opensource@clickalicious.de>
@return integer Week
@access public
968435
public function getWeek($timestamp = false)
    {
        if (!$timestamp) {
            $timestamp = $this->dateTime->getTimestamp();
        }

        return (int) date('W', $timestamp);
    }
905267
static function makeDateTime(int $timestamp) {
        $zone = new \DateTimeZone(\date_default_timezone_get());
        return (new \DateTime('@'.$timestamp))->setTimezone($zone);
    }
792256
public function calculate_expiry($timestamp) {
        $expiry = null;

        if (isset($this->expiredate)) {
            $expiry = $this->expiredate;
        } else if (isset($this->expireperiod)) {
            $expiry = $timestamp + $this->expireperiod;
        }

        return $expiry;
    }
875901
public static function isoDate($timestamp = null)
    {
        $tz = date_default_timezone_get();
        date_default_timezone_set('UTC');

        if (is_null($timestamp)) {
            $timestamp = time();
        }

        $returnValue = str_replace(
            '+00:00', '.0000000Z', date('c', $timestamp)
        );
        date_default_timezone_set($tz);

        return $returnValue;
    }
426863
public function setTimestamp($timestamp)
    {
        if (!$timestamp instanceof \DateTime) {
            $date = new \DateTime();
            $date->setTimestamp($timestamp);
        } else {
            $date = $timestamp;
        }
        $this->header['TIMESTAMP'] = $date->format('M d H:i:s');
        return $this;
    }
611455
public function getDelayedTimestampSize($timestamp)
    {
        $timestamp = $this->toTimestamp($timestamp);
        return $this->redis->llen('delayed:' . $timestamp, $timestamp);
    }
1281946
public function revisionAtTimestamp($timestamp)
    {
        $revision = $this->revisions()
                         ->where('created_at', '<=', Carbon::parse($timestamp))
                         ->first();

        return $this->wrapRevision($revision);
    }
774053
protected function timestampHasExpired(int $timestamp): bool
    {
        $date = Carbon::createFromTimestamp($timestamp, 'UTC');
        $start = Carbon::now('UTC')->subSeconds($this->timestampExpires);
        $end = Carbon::now('UTC');

        return !$date->between($start, $end);
    }
414099
public static function timeFriendly($timestamp = null)
    {
        if ($timestamp == null) {
            return 'N/A';
        }
        
        // 获取当前时间戳
        $currentTime = time();
        
        // 获取当天0点时间戳
        $todayZero = strtotime('today');
        
        // 获取昨天时间戳
        $yesterday = strtotime('-1 day', $todayZero);
        
        // 获取前天时间戳
        $beforeYesterday = strtotime('-1 day', $yesterday);
        
        // 获取明天0点时间戳
        $tomorrow = strtotime('+1 day', $todayZero);
        
        // 获取后天0点时间戳
        $afterTomorrow = strtotime('+1 day', $tomorrow);
        
        // 获取一天的时间戳
        $oneDayTimestamp = 3600 * 24;
        
        //当年时间戳
        $yearDiff = $currentTime - strtotime("-1 year");
        
        // 时间差
        $timeDiff = $currentTime - $timestamp;
        
        switch (true) {
            case $timestamp >= $afterTomorrow && $timestamp < $afterTomorrow + $oneDayTimestamp :
                return Yii::t('wocenter/app', 'The day after tomorrow {time}', ['time' => date('H:i', $timestamp)]);
            case $timestamp >= $tomorrow && $timestamp < $afterTomorrow :
                return Yii::t('wocenter/app', 'Tomorrow {time}', ['time' => date('H:i', $timestamp)]);
            case $timestamp >= $todayZero && $timestamp < $tomorrow :
                if ($timeDiff < (3600 * 8)) {
                    return Yii::$app->getFormatter()->asRelativeTime($timestamp);
                } else {
                    return Yii::t('wocenter/app', 'Today {time}', ['time' => date('H:i', $timestamp)]);
                }
            case $timestamp >= $yesterday && $timestamp < $todayZero :
                return Yii::t('wocenter/app', 'Yesterday {time}', ['time' => date('H:i', $timestamp)]);
            case $timestamp >= $beforeYesterday && $timestamp < $yesterday :
                return Yii::t('wocenter/app', 'The day before yesterday {time}', ['time' => date('H:i', $timestamp)]);
            default :
                if ($timeDiff > $yearDiff) {
                    return date('Y-m-d H:i', $timestamp);
                } else {
                    return date('m-d H:i', $timestamp);
                }
        }
    }
180155
public static function isTimestamp($timestamp)
    {
        if (is_bool($timestamp) || !is_scalar($timestamp)) {
            return false;
        }
        return ((string)(int)$timestamp === (string)$timestamp)
        && ($timestamp <= PHP_INT_MAX)
        && ($timestamp >= ~PHP_INT_MAX);
    }
657034
public static function timeFormat($timestamp = null, $format = 'Y-m-d H:i:s')
    {
        if ($timestamp === null) {
            $timestamp = time();
        } elseif (empty($timestamp)) {
            return null;
        } else {
            $timestamp = intval($timestamp);
        }
        if (strncmp($format, 'php:', 4) === 0) {
            $format = substr($format, 4);
        }
        
        return date($format, $timestamp);
    }
430489
public function elapsedTime($timestamp)
    {
        if ($timestamp instanceof DateTime) {
            $timestamp = $timestamp->format('U');
        } else if (is_string($timestamp)) {
            $timestamp = strtotime($timestamp);
        }
        
        $diff = time() - $timestamp; 
        $periods = self::$texts['times']; 
        $lengths = array(60, 60, 24, 7, 4.35, 12, 10); 
        $ending = self::$texts['ago'];
        
        if ($diff < 60) {
            return self::$texts['less_than_a_minute'];
        } else if ($diff < 0) {
            $diff = -$diff; 
            $ending = self::$texts['togo']; 
        }
              
        for($j = 0; $j < count($lengths) && $diff >= $lengths[$j]; $j++) {
            $diff /= $lengths[$j]; 
        }
        $diff = round($diff); 
        if($diff != 1) {
            $periods[$j].= "s"; 
        }
        
        if (self::$agoAfter) {
            return "$diff $periods[$j] $ending";
        } else {
            return "$ending $diff $periods[$j]";
        }
    }
1235396
public static function distance($timestamp)
    {
        $second = $timestamp - time();
        if ($second > 0) {
            $day = floor($second / (3600 * 24));
            $second = $second % (3600 * 24);//除去整天之后剩余的时间
            $hour = floor($second / 3600);
            $second = $second % 3600;//除去整小时之后剩余的时间
            $minute = floor($second / 60);
            $second = $second % 60;//除去整分钟之后剩余的时间

            $distance = [
                'day' => $day,
                'hour' => $hour,
                'minute' => $minute,
            ];
            return $distance;
        }
    }
837675
public static function longDate($timestamp = null)
    {
        $l = self::getLocale();
        return self::date($l->shortDateTime, $timestamp);
    }
870025
public function monthname($timestamp = 0)
    {
        // get month from timestamp
        $month = (int) date('n', $timestamp) - 1;

        // return translated (localized) month-name
        return $this->translator->_($this->month[$month]);
    }
1318156
public static function ToDate($Timestamp = '') {
      if ($Timestamp == '')
         $Timestamp = time();
      elseif (!is_numeric($Timestamp))
         $Timestamp = self::ToTimestamp($Timestamp);

      return date('Y-m-d', $Timestamp);
   }
1241625
private function getDosTime($timestamp = 0) {
        $timestamp = (int)$timestamp;
        $oldTZ = @date_default_timezone_get();
        date_default_timezone_set('UTC');
        $date = ($timestamp == 0 ? getdate() : getdate($timestamp));
        date_default_timezone_set($oldTZ);
        if ($date["year"] >= 1980) {
            return pack("V", (($date["mday"] + ($date["mon"] << 5) + (($date["year"]-1980) << 9)) << 16) |
                             (($date["seconds"] >> 1) + ($date["minutes"] << 5) + ($date["hours"] << 11)));
        }
        return "\x00\x00\x00\x00";
    }