Returns "weeks ago" like string
@param integer $weeks
@return string
338439
public function weeks($weeks)
    {
        return sprintf($this->formatPattern, $weeks, $this->week_words[$this->pluralization($weeks)]);
    }
1309824
public function seeWeekInMonth($date, $week) {
        \PHPUnit_Framework_Assert::assertEquals($week, $this->_ParseDate($date)->weekOfMonth);
    }
1142425
public function thisWeek()
    {
        $scheduleWeek = $this->scheduler->getScheduleWeek();
        $currentWeek = $this->now->format('W');

        //if a month is defined, week refers to the week of the month
        $scheduleMonth = $this->scheduler->getScheduleMonth();
        if (!is_null($scheduleMonth) && $scheduleMonth !== Scheduler::NONE) {
            return $this->isCurrent($scheduleWeek, $this->now->weekOfMonth);
        }

        //if it's an odd or even week
        if ($scheduleWeek == 'odd' && $currentWeek & 1) {
            return true;
        } elseif ($scheduleWeek == 'even' && !($currentWeek & 1)) {
            return true;
        }

        return $this->isCurrent($scheduleWeek, $this->now->weekOfYear);
    }
1236007
public function longFormat($duration)
	{
		if( isset($duration) ) $this->__construct($duration);
		if( $this->hoursSection >= 1 )
		{
			return sprintf(
				' %s ' . str_plural('hour', $this->hoursSection) .
				' %s ' . str_plural('minute', $this->minutesSection) .
				' %s ' . str_plural('second', $this->secondsSection)
				, $this->hoursSection, $this->minutesSection, $this->secondsSection);
		}
		if( $this->minutesSection >= 1 && $this->secondsSection )
		{
			return sprintf(
				' %s ' . str_plural('minute', $this->minutesSection) .
				' %s ' . str_plural('second', $this->secondsSection)
				, $this->minutesSection, $this->secondsSection);
		}
		if( $this->minutesSection >= 1 )
		{
			return sprintf(
				' %s ' . str_plural('minute', $this->minutesSection)
				, $this->minutesSection);
		}


		return sprintf(' %s ' . str_plural('second', $this->secondsSection), $this->secondsSection);
	}
1092041
public function isoWeek($week = null, $dayOfWeek = null, $dayOfYear = null)
    {
        return $this->week(
            $week,
            $dayOfWeek ?? 1,
            $dayOfYear ?? 4
        );
    }
436384
protected function getCode( $heading, $weekdays, $weeks )
	{
		if( $template = $this->getOption( 'template' ) )
		{
			$options	= $this->getOptions();
			require( $template );
		}
		else
		{
			$clearFix	= UI_HTML_Tag::create( 'div', "", array( 'style' => 'clear: both' ) );
			$content	= UI_HTML_Tag::create( 'div', $heading.$weekdays.$weeks.$clearFix, array( 'class' => 'calendar' ) );
		}
		return $content;
	}
11705
public CalendarWeek minus(Weeks weeks) {

        if (weeks.isEmpty()) {
            return this;
        }

        PlainDate date = this.start.getTemporal().minus(weeks.getAmount(), CalendarUnit.WEEKS);
        int y = date.getInt(YEAR_OF_WEEKDATE);
        int w = date.getInt(WEEK_OF_YEAR);
        return CalendarWeek.of(y, w);

    }
998398
public static function weeksInYear(int $y) : int
    {
        $lWeek = self::lastWeekOfYear($y);
        return (int)$lWeek->format("W");
    }
490000
public function cleanOldEntryLogs($days = null)
	{
	    if(!isset($days))
	    {
	       $days = $this->_configRead('days_to_keep_logs');
	    }

	    if(!empty($days) && $days > 0)
	    {
	        $log_levels_to_keep     = $this->_configRead('log_levels_to_keep');
	        $log_categories_to_keep = $this->_configRead('log_categories_to_keep');

	        /*
	         * Find all EntryLogs that are:
	         * - older than $days_to_keep_logs days
	         * - whose log level is not in $log_levels_to_keep
	         * - whose log category is not in $log_categories_to_keep
	         *
	         * then delete them
	         */

	        $query = TableRegistry::get('Alaxos.LogEntries')->query();
	        $query->delete();

	        $query->where(function($exp) use ($days){
	            return $exp->lte('created', (new Time('-' . $days . ' days'))->toDateTimeString());
	        });

	        if(!empty($log_levels_to_keep))
	        {
	            $query->where(function($exp) use ($log_levels_to_keep){
	                return $exp->not(['log_level_id' => $log_levels_to_keep], ['log_level_id' => 'integer[]']);
	            });
	        }

	        if(!empty($log_categories_to_keep))
	        {
	            $query->where(function($exp) use ($log_categories_to_keep){
	                return $exp->not(['log_category_id IN' => $log_categories_to_keep]);
	            });
	        }

	        //$query->connection()->logQueries(true);
	        //debug($query->__debugInfo()['sql']);

	        $statement = $query->execute();
	        $deleted_total = $statement->rowCount();

	        //$query->connection()->logQueries(false);
	    }
	}
754288
public function episodeWeekEnd()
    {
        $endDay  = (string) $this->getRequiredParameter('endDay'); // sun,mon,tue,wed,thu,fri,sat
        $endTime = (string) $this->getRequiredParameter('endTime'); // H:i:s

        $now = $this->DateFactory->newLocalDate();
        $today = strtolower($now->format('D'));

	    if ($endDay == $today) {
            $weekEnd = $now;
            if ($now > $this->DateFactory->newLocalDate($now->format('Y-m-d') . ' ' . $endTime))
                $weekEnd = $now->modify('+1 week');
	    } else {
            $weekEnd = $now->modify('next ' . $endDay);
        }
	    return $weekEnd->format('Y-m-d');
    }
919601
public function eachWeeks($weeks = 1, \Closure $callback, $onlyFullWeek = false)
    {
        if ($this->lengthInWeeks() > 0) {
            return $this->each(
                new \DateInterval("P{$weeks}W"),
                function (CarbonPeriod $period) use ($weeks, $callback, $onlyFullWeek) {
                    if (!$onlyFullWeek || $period->lengthInWeeks() === $weeks) {
                        call_user_func_array($callback, func_get_args());
                    }
                }
            );
        }

        return $this;
    }
907143
public function getFormattedDuration($seconds)
    {
        $duration = ceil($seconds) . ' seconds';

        if ($duration > 60) {
            $duration = round($duration / 60, 1) . ' minutes';
        } elseif ($duration > 3600) {
            $duration = round($duration / (60 * 60), 1) . ' hours';
        } elseif ($duration > (24 * 60 * 60)) {
            $duration = round($duration / (24 * 60 * 60), 1) . ' days';
        }

        return $duration;
    }
1252571
public static function getWeeksAgo($ago, $endDateTime = null)
    {
        return static::getDateTimeRange(
            Carbon::now()->subWeeks($ago)->startOfWeek(),
            $endDateTime ?: Carbon::now()->subWeeks($ago)->endOfWeek()
        );
    }
313483
public function minusWeeks(int $weeks) : LocalDateTime
    {
        if ($weeks === 0) {
            return $this;
        }

        return new LocalDateTime($this->date->minusWeeks($weeks), $this->time);
    }
713187
public static function lastWeekRange()
    {
        $timestamp = time();
        return [
            strtotime(date('Y-m-d', strtotime("last week Monday", $timestamp))),
            strtotime(date('Y-m-d', strtotime("last week Sunday", $timestamp))) + 24 * 3600 - 1
        ];
    }
1246794
public static function dateRangeInWeek($week = 0, $year = 0)
    {
        /*
          Fungsi ini untuk mendapatkan nilai tanggal berapa saja dalam minggu tertentu
          Tanggal dimulai pada hari senin pada minggu tersebut.
          returned type: array
         */
        $year = (int)$year;
        $week = (int)$week;
        if ($year < 1970) { // minimal unix time year 1970
            $year = date("Y");
            $week = date("W");
        }
        if ($week <= 0 || $week > 54) {
            $week = date("W");
            $year = date("Y");
        }
        //cek apakah tanggal 1 masuk minggu pertama atau minggu terakhir tahun sebelumnya
        $mingguTanggalAwalTahun   = date("W", mktime(1, 0, 0, 1, 1, $year));
        $jumlahDetikDalamSehari   = 24 * 60 * 60;
        $jumlahDetikDalamSeminggu = $jumlahDetikDalamSehari * 7;
        $hariAwalTahun            = date("w", mktime(1, 0, 0, 1, 1, $year));
        // Hari ke 0/7->minggu 1->Senin 2->Selasa 3->Rabu 4->Kamis 5->Jumat 6->Sabtu
        $detikAwalTahun = date("U", mktime(1, 0, 0, 1, 1, $year));
        if ($hariAwalTahun == 0) {
            $hariAwalTahun = 7; // ISO-8601 numeric representation
        }
        $jumlahHariPadaMingguPertama = (7 - $hariAwalTahun) + 1; //Long variable name but easily understood :P
        $detikTambahan               = (($week - 1) * $jumlahDetikDalamSeminggu) + ($jumlahHariPadaMingguPertama * $jumlahDetikDalamSehari);
        if ($mingguTanggalAwalTahun == 1) {
            $tanggalUnixSenin = $detikAwalTahun + $detikTambahan;
        } else {
            $tanggalUnixSenin = $detikAwalTahun + $detikTambahan + $jumlahDetikDalamSeminggu;
        }
        $dateRange = array();
        for ($i = 1; $i <= 7; $i++) {
            $dateRange[$i] = date("Y-m-d", ($tanggalUnixSenin + (($i - 1) * $jumlahDetikDalamSehari) - $jumlahDetikDalamSeminggu));
        }

        return $dateRange;
    }
353389
public function getTimeDiff(DateTime $releaseDate)
    {
        $now = new DateTime();

        /** @var DateInterval $diff */
        $diff = $now->diff($releaseDate);

        if ($diff->days > 7) {
            return '';
        }

        if ($diff->days == 7) {
            return 'a week ago';
        }

        if ($diff->days >= 1) {
            return sprintf('%d day(s) ago', $diff->days);
        }

        if ($diff->h >= 1) {
            return sprintf('%d hour(s) ago', $diff->h);
        }

        if ($diff->i >= 1) {
            return sprintf('%d minute(s) ago', $diff->i);
        }

        return 'just now';
    }