[WIP] Setup of skeleton
This commit is contained in:
52
app/Repositories/Core/DateHelper.php
Normal file
52
app/Repositories/Core/DateHelper.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use \Carbon\Carbon;
|
||||
use \League\Period\Period;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user