[WIP] Setup of skeleton
This commit is contained in:
59
app/Repositories/Core/DateTime.php
Normal file
59
app/Repositories/Core/DateTime.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class DateTime
|
||||
{
|
||||
public static function getLang()
|
||||
{
|
||||
return session('locale') ? session('locale') : 'fr';
|
||||
}
|
||||
|
||||
public static function convert($date)
|
||||
{
|
||||
return $date ? Carbon::createFromFormat('d/m/Y', $date)->isoFormat('Y-MM-DD') : null;
|
||||
}
|
||||
|
||||
public static function convertTime($date)
|
||||
{
|
||||
return $date ? Carbon::createFromFormat('d/m/Y H:i', $date)->isoFormat('Y-MM-DD HH:mm:ss') : null;
|
||||
}
|
||||
|
||||
public static function toFr($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->isoFormat('DD/MM/Y') : null;
|
||||
}
|
||||
|
||||
public static function toFrTime($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->isoFormat('DD/MM/Y HH:mm:ss') : null;
|
||||
}
|
||||
|
||||
public static function FromDatetimeFr($date)
|
||||
{
|
||||
return $date ? Carbon::createFromFormat('d/m/Y H:i:s', $date) : null;
|
||||
}
|
||||
|
||||
public static function DatetimeToStamp($date)
|
||||
{
|
||||
return $date ? self::FromDatetimeFr($date)->isoFormat('Y-MM-DD HH:mm:ss') : null;
|
||||
}
|
||||
|
||||
public static function DatetimeToDate($date)
|
||||
{
|
||||
return $date ? self::FromDatetimeFr($date)->isoFormat('DD/MM/Y') : null;
|
||||
}
|
||||
|
||||
public static function DatetimeToTime($date)
|
||||
{
|
||||
return $date ? self::FromDatetimeFr($date)->isoFormat('HH:mm') : null;
|
||||
}
|
||||
|
||||
public static function isPast($date)
|
||||
{
|
||||
return self::FromDatetimeFr($date)->isPast();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user