Synchro back-office, fix on tariffs

This commit is contained in:
Ludovic CANDELLIER
2021-10-26 21:41:46 +02:00
parent c150be2c3e
commit 86f6ee9a13
45 changed files with 1095 additions and 406 deletions

View File

@@ -36,7 +36,7 @@ class DateTime
if (!is_null($date) && !empty($date)) {
$date = Carbon::parse($date)->format($format);
} elseif ($date == 'now') {
$date = Carbon::now()->format($format);
$date = today()->format($format);
}
return $date;
}
@@ -47,7 +47,7 @@ class DateTime
if (!is_null($date) && !empty($date)) {
$date = Carbon::parse($date)->format($format);
} elseif ($date == 'now') {
$date = Carbon::now()->format($format);
$date = now()->format($format);
}
return $date;
}
@@ -76,6 +76,9 @@ class DateTime
public static function convertTime($date)
{
$format = self::getLocaleFormatDatetime();
if (strlen($date) == 16) {
$date .= ':00';
}
return !empty($date) ? Carbon::createFromFormat($format, $date)->isoFormat('Y-MM-DD HH:mm:ss') : null;
}
@@ -102,12 +105,12 @@ class DateTime
{
$locale = self::getLang();
switch ($locale) {
case 'fr':
case 'en':
$format = 'd/m/Y';
break;
default:
$format = 'Y-m-d';
case 'fr':
case 'en':
$format = 'd/m/Y';
break;
default:
$format = 'Y-m-d';
}
return $format;
}
@@ -116,29 +119,45 @@ class DateTime
{
$locale = self::getLang();
switch ($locale) {
case 'fr':
case 'en':
$format = 'd/m/Y H:i:s';
break;
default:
$format = 'Y-m-d H:i:s';
case 'fr':
case 'en':
$format = 'd/m/Y H:i:s';
break;
default:
$format = 'Y-m-d H:i:s';
}
return $format;
}
public static function getLocaleDateFull($date)
public static function getLocaleDateFull($date = false)
{
return Carbon::parse($date)->isoFormat('LLLL');
return self::getISOFormat('LL', $date);
}
public static function getLocaleDateFullShort($date)
public static function getLocaleDateTimeFull($date = false)
{
return Carbon::parse($date)->isoFormat('lll');
return self::getISOFormat('LLL', $date);
}
public static function getLocaleHour($date)
public static function getLocaleDateFullShort($date = false)
{
return Carbon::parse($date)->isoFormat('');
return self::getISOFormat('ll', $date);
}
public static function getLocaleDateTimeFullShort($date = false)
{
return self::getISOFormat('lll', $date);
}
public static function getLocaleTime($date = false)
{
return self::getISOFormat('LT', $date);
}
public static function getISOFormat($format, $date = false)
{
$date = $date ? $date : now();
return Carbon::parse($date)->isoFormat($format);
}
public static function relativeTime()