[增添]添加了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,2 @@
# Auto detect text files and perform LF normalization
* text=auto

View File

@@ -0,0 +1 @@
github: [danharrin]

View File

@@ -0,0 +1,23 @@
---
name: Bug report
about: Create a report to help us improve
labels: bug
assignees: DanHarrin
---
**Describe the bug**
A clear and concise description of what the bug is.
**To reproduce**
A simplified code example to demonstrate the issue you are facing.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Context**
- Package version: [e.g. 0.1.0]
- Server OS: [e.g. Ubuntu 18.04.4]
- PHP version: [e.g. 7.4]
**Additional details**
Add any other details about the problem here.

View File

@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Feature request
url: https://github.com/danharrin/date-format-converter/discussions/new
about: For ideas or feature requests
- name: Support questions & other
url: https://github.com/danharrin/date-format-converter/discussions/new
about: If you have a question or need help installing using the package

View File

@@ -0,0 +1,2 @@
/vendor
composer.lock

View File

@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting Dan Harrin at dan@danharrin.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

View File

@@ -0,0 +1,21 @@
# MIT License
Copyright (c) Dan Harrin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,33 @@
<p align="center">
<img src="https://user-images.githubusercontent.com/41773797/107574578-c4014600-6be6-11eb-8309-acca0acdd6f5.png" alt="Package banner" style="width: 100%; max-width: 800px;" />
</p>
This package allows you to convert token-based date formats between standards.
## Installation
You can use Composer to install this package into your application:
```
composer require danharrin/date-format-converter
```
## Usage
Use the `convert_date_format()` method to initialise a new instance of the converter, ready to use:
```php
convert_date_format('Y-m-d H:i:s')->to('day.js');
// YYYY-MM-DD HH:mm:ss
convert_date_format('Y-m-d H:i:s')->to('moment.js');
// YYYY-MM-DD HH:mm:ss
```
## Need Help?
🐞 If you spot a bug with this package, please [submit a detailed issue](https://github.com/danharrin/date-format-converter/issues/new), and wait for assistance.
🤔 If you have a question or feature request, please [start a new discussion](https://github.com/danharrin/date-format-converter/discussions/new).
🔐 If you discover a vulnerability within the package, please review our [security policy](https://github.com/danharrin/date-format-converter/blob/main/SECURITY.md).

View File

@@ -0,0 +1,11 @@
# Security Policy
## Supported Versions
| Version | Supported |
| ------- | ------------------ |
| 0.x | :white_check_mark: |
## Reporting a Vulnerability
If you discover a security vulnerability within the package, please email Dan Harrin via [dan@danharrin.com](mailto:dan@danharrin.com). All security vulnerabilities will be promptly addressed.

View File

@@ -0,0 +1,32 @@
{
"name": "danharrin/date-format-converter",
"description": "Convert token-based date formats between standards.",
"license": "MIT",
"homepage": "https://github.com/danharrin/date-format-converter",
"support": {
"issues": "https://github.com/danharrin/date-format-converter/issues",
"source": "https://github.com/danharrin/date-format-converter"
},
"authors": [
{
"name": "Dan Harrin",
"email": "dan@danharrin.com"
}
],
"require": {
"php": "^7.2|^8.0"
},
"autoload": {
"files": [
"src/helpers.php",
"src/standards.php"
],
"psr-4": {
"DanHarrin\\DateFormatConverter\\": "src/"
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev"
}

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',
],
];