<?php

namespace App\Repositories\Core;

use Carbon\Carbon;

class DateHelper
{
    public static function byDay()
    {
        return Carbon::now()->startOfDay();
    }

    public static function byWeek()
    {
        return Carbon::now()->startOfWeek();
    }

    public static function byMonth()
    {
        return Carbon::now()->startOfMonth();
    }

    public static function byQuarter()
    {
        return Carbon::now()->startOfQuarter();
    }

    public static function bySemester()
    {
        $quarter = Carbon::now()->quarter;
        switch ($quarter) {
            case 1:
            case 2:
                $date = Carbon::now()->startOfYear();
                break;
            case 3:
                $date = Carbon::now()->startOfQuarter();
                break;
            case 4:
                $date = Carbon::now()->subMonth(3)->startOfQuarter();
                break;
        }

        return $date;
    }

    public static function byYear()
    {
        return Carbon::now()->startOfYear();
    }
}
