From 8e0058392d27de15882c43912c306950043115b7 Mon Sep 17 00:00:00 2001 From: eliseekn Date: Mon, 2 Oct 2023 18:54:05 +0000 Subject: [PATCH] Feat #4 Update README.md --- .idea/.gitignore | 8 +++ .idea/blade.xml | 117 ++++++++++++++++++++++++++++++++ .idea/codeception.xml | 30 ++++++++ .idea/laravel-idea-personal.xml | 10 +++ .idea/laravel-idea.xml | 7 ++ .idea/laravel-metrics.iml | 60 ++++++++++++++++ .idea/modules.xml | 8 +++ .idea/php.xml | 77 +++++++++++++++++++++ .idea/phpspec.xml | 28 ++++++++ .idea/phpunit.xml | 10 +++ .idea/vcs.xml | 6 ++ README.md | 2 +- src/LaravelMetrics.php | 6 +- 13 files changed, 366 insertions(+), 3 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/blade.xml create mode 100644 .idea/codeception.xml create mode 100644 .idea/laravel-idea-personal.xml create mode 100644 .idea/laravel-idea.xml create mode 100644 .idea/laravel-metrics.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/phpspec.xml create mode 100644 .idea/phpunit.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/blade.xml b/.idea/blade.xml new file mode 100644 index 0000000..6de0825 --- /dev/null +++ b/.idea/blade.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeception.xml b/.idea/codeception.xml new file mode 100644 index 0000000..a4b8325 --- /dev/null +++ b/.idea/codeception.xml @@ -0,0 +1,30 @@ + + + + + + \ No newline at end of file diff --git a/.idea/laravel-idea-personal.xml b/.idea/laravel-idea-personal.xml new file mode 100644 index 0000000..101257b --- /dev/null +++ b/.idea/laravel-idea-personal.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/laravel-idea.xml b/.idea/laravel-idea.xml new file mode 100644 index 0000000..793d126 --- /dev/null +++ b/.idea/laravel-idea.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/laravel-metrics.iml b/.idea/laravel-metrics.iml new file mode 100644 index 0000000..4d12daa --- /dev/null +++ b/.idea/laravel-metrics.iml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..1526e68 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..f0df056 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/phpspec.xml b/.idea/phpspec.xml new file mode 100644 index 0000000..3ba44d7 --- /dev/null +++ b/.idea/phpspec.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/phpunit.xml b/.idea/phpunit.xml new file mode 100644 index 0000000..4f8104c --- /dev/null +++ b/.idea/phpunit.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index d1126ea..5a18f46 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ LaravelMetrics::query(...) ->byWeek(int $count = 0) // or ->byMonth(int $count = 0) // or ->byYear(int $count = 0) // or - ->between(string $startDate, string $endDate) + ->between(string $startDate, string $endDate, string $isoFormat) ``` **Note :** Periods are defined for the current day, week, month or year by default. However, you can define a specific value using dedicated methods. For example: diff --git a/src/LaravelMetrics.php b/src/LaravelMetrics.php index ec9077f..f74d98a 100644 --- a/src/LaravelMetrics.php +++ b/src/LaravelMetrics.php @@ -34,6 +34,7 @@ class LaravelMetrics protected int $month; protected int $day; protected int $week; + protected string $isoFormat = 'YYYY-MM-DD'; public function __construct(protected Builder|QueryBuilder $builder) { @@ -91,10 +92,11 @@ public function byYear(int $count = 0): self return $this->by(Period::YEAR->value, $count); } - public function between(string $start, string $end): self + public function between(string $start, string $end, string $isoFormat = 'YYYY-MM-DD'): self { $this->checkDateFormat([$start, $end]); $this->period = [$start, $end]; + $this->isoFormat = $isoFormat; return $this; } @@ -426,7 +428,7 @@ protected function formatDate(Collection $data): Collection } elseif ($this->period === Period::YEAR->value) { $datum->label = intval($datum->label); } else { - $datum->label = Carbon::parse($datum->label)->locale(self::locale())->toFormattedDateString(); + $datum->label = Carbon::parse($datum->label)->locale(self::locale())->isoFormat($this->isoFormat); } return $datum;