[增添]添加了datasource的setting数据库以及默认值

This commit is contained in:
makotocc0107
2024-08-27 09:57:44 +08:00
parent d111dfaea4
commit 72eb990970
10955 changed files with 978898 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace DanHarrin\DateFormatConverter;
class Converter
{
public $format;
public function __construct($format)
{
$this->format = $format;
}
public function to($standard)
{
$format = '';
$escape = false;
foreach (str_split($this->format) as $token) {
if ($token === '[') {
$escape = true;
}
if ($escape) {
if ($token === ']') {
$escape = false;
}
$format .= $token;
continue;
}
$format .= array_key_exists($token, DATE_FORMAT_STANDARDS) ?
DATE_FORMAT_STANDARDS[$token][$standard] :
$token;
}
return $format;
}
}

View File

@@ -0,0 +1,10 @@
<?php
use DanHarrin\DateFormatConverter\Converter;
if (! function_exists('convert_date_format')) {
function convert_date_format($format)
{
return new Converter($format);
}
}

View File

@@ -0,0 +1,154 @@
<?php
namespace DanHarrin\DateFormatConverter;
const DATE_FORMAT_STANDARDS = [
'A' => [
'day.js' => 'A',
'moment.js' => 'A',
],
'a' => [
'day.js' => 'a',
'moment.js' => 'a',
],
'B' => [
'day.js' => '',
'moment.js' => '',
],
'c' => [
'day.js' => '',
'moment.js' => '',
],
'D' => [
'day.js' => 'ddd',
'moment.js' => 'ddd',
],
'd' => [
'day.js' => 'DD',
'moment.js' => 'DD',
],
'e' => [
'day.js' => '',
'moment.js' => '',
],
'F' => [
'day.js' => 'MMMM',
'moment.js' => 'MMMM',
],
'G' => [
'day.js' => 'H',
'moment.js' => 'H',
],
'g' => [
'day.js' => 'h',
'moment.js' => 'h',
],
'H' => [
'day.js' => 'HH',
'moment.js' => 'HH',
],
'h' => [
'day.js' => 'hh',
'moment.js' => 'hh',
],
'i' => [
'day.js' => 'mm',
'moment.js' => 'mm',
],
'I' => [
'day.js' => '',
'moment.js' => '',
],
'j' => [
'day.js' => 'D',
'moment.js' => 'D',
],
'L' => [
'day.js' => '',
'moment.js' => '',
],
'l' => [
'day.js' => 'dddd',
'moment.js' => 'dddd',
],
'M' => [
'day.js' => 'MMM',
'moment.js' => 'MMM',
],
'm' => [
'day.js' => 'MM',
'moment.js' => 'MM',
],
'N' => [
'day.js' => '',
'moment.js' => 'E',
],
'n' => [
'day.js' => 'M',
'moment.js' => 'M',
],
'O' => [
'day.js' => 'ZZ',
'moment.js' => 'ZZ',
],
'o' => [
'day.js' => '',
'moment.js' => '',
],
'P' => [
'day.js' => 'Z',
'moment.js' => 'Z',
],
'p' => [
'day.js' => '',
'moment.js' => '',
],
'r' => [
'day.js' => '',
'moment.js' => '',
],
'S' => [
'day.js' => 'o',
'moment.js' => 'o',
],
's' => [
'day.js' => 'ss',
'moment.js' => 'ss',
],
'T' => [
'day.js' => '',
'moment.js' => '',
],
't' => [
'day.js' => '',
'moment.js' => '',
],
'U' => [
'day.js' => '',
'moment.js' => '',
],
'u' => [
'day.js' => '',
'moment.js' => '',
],
'v' => [
'day.js' => 'SSS',
'moment.js' => 'SSS',
],
'w' => [
'day.js' => '',
'moment.js' => 'e',
],
'Y' => [
'day.js' => 'YYYY',
'moment.js' => 'YYYY',
],
'y' => [
'day.js' => 'YY',
'moment.js' => 'YY',
],
'X' => [
'day.js' => '',
'moment.js' => 'DDDD',
],
];