Skip to content

Commit ba5f8cd

Browse files
committed
Update README.md and add more DateRange tests
1 parent a5a5bc1 commit ba5f8cd

File tree

3 files changed

+359
-18
lines changed

3 files changed

+359
-18
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,15 @@ $dateParser = (new DateParser('<2023-07-01', 'America/New_York'))->formatTo('Y-m
148148
149149
### Class `DateParser`
150150
151-
| method | description | type |
152-
|--------------------------------------|--------------------------------------------------------|---------------------------|
153-
| <nobr>`->formatFrom($format)`</nobr> | Returns the formatted "from" date. | `string` |
154-
| <nobr>`->formatTo($format)`</nobr> | Returns the formatted "to" date. | `string` |
155-
| <nobr>`->getDateRange()`</nobr> | Returns the range as `DateRange` class. | `DateRange` |
156-
| <nobr>`->getFrom()`</nobr> | Returns the "from" date as `DateTime` object. | `DateTime\|null` |
157-
| <nobr>`->getTo()`</nobr> | Returns the "to" date as `DateTime` object. | `DateTime\|null` |
158-
| <nobr>`->getFromImmutable()`</nobr> | Returns the "from" date as `DateTimeImmutable` object. | `DateTimeImmutable\|null` |
159-
| <nobr>`->getToImmutable()`</nobr> | Returns the "to" date as `DateTimeImmutable` object. | `DateTimeImmutable\|null` |
151+
| method | description | type |
152+
|-------------------------------------------------------------------------------|--------------------------------------------------------|---------------------------|
153+
| <nobr>`->formatFrom(string $format, DateTimeZone $dateTimeZoneOutput)`</nobr> | Returns the formatted "from" date. | `string` |
154+
| <nobr>`->formatTo(string $format, DateTimeZone $dateTimeZoneOutput)`</nobr> | Returns the formatted "to" date. | `string` |
155+
| <nobr>`->getDateRange()`</nobr> | Returns the range as `DateRange` class. | `DateRange` |
156+
| <nobr>`->getFrom(DateTimeZone $dateTimeZoneOutput)`</nobr> | Returns the "from" date as `DateTime` object. | `DateTime\|null` |
157+
| <nobr>`->getTo(DateTimeZone $dateTimeZoneOutput)`</nobr> | Returns the "to" date as `DateTime` object. | `DateTime\|null` |
158+
| <nobr>`->getFromImmutable(DateTimeZone $dateTimeZoneOutput)`</nobr> | Returns the "from" date as `DateTimeImmutable` object. | `DateTimeImmutable\|null` |
159+
| <nobr>`->getToImmutable(DateTimeZone $dateTimeZoneOutput)`</nobr> | Returns the "to" date as `DateTimeImmutable` object. | `DateTimeImmutable\|null` |
160160
161161
## Development
162162

src/DateParser.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Ixnode\PhpDateParser\Base\BaseDateParser;
2020
use Ixnode\PhpDateParser\Constants\Timezones;
2121
use Ixnode\PhpDateParser\Tests\Unit\DateParserTest;
22+
use Ixnode\PhpException\Case\CaseUnsupportedException;
2223

2324
/**
2425
* Class DateParser
@@ -46,6 +47,7 @@ public function getDateRange(): DateRange
4647
* @param string $format
4748
* @param DateTimeZone $dateTimeZoneOutput
4849
* @return string|null
50+
* @throws CaseUnsupportedException
4951
*/
5052
public function formatFrom(string $format, DateTimeZone $dateTimeZoneOutput = new DateTimeZone(Timezones::UTC)): string|null
5153
{
@@ -58,6 +60,7 @@ public function formatFrom(string $format, DateTimeZone $dateTimeZoneOutput = ne
5860
* @param string $format
5961
* @param DateTimeZone $dateTimeZoneOutput
6062
* @return string|null
63+
* @throws CaseUnsupportedException
6164
*/
6265
public function formatTo(string $format, DateTimeZone $dateTimeZoneOutput = new DateTimeZone(Timezones::UTC)): string|null
6366
{
@@ -69,6 +72,7 @@ public function formatTo(string $format, DateTimeZone $dateTimeZoneOutput = new
6972
*
7073
* @param DateTimeZone $dateTimeZoneOutput
7174
* @return DateTime|null
75+
* @throws CaseUnsupportedException
7276
*/
7377
public function getFrom(DateTimeZone $dateTimeZoneOutput = new DateTimeZone(Timezones::UTC)): DateTime|null
7478
{
@@ -80,6 +84,7 @@ public function getFrom(DateTimeZone $dateTimeZoneOutput = new DateTimeZone(Time
8084
*
8185
* @param DateTimeZone $dateTimeZoneOutput
8286
* @return DateTime|null
87+
* @throws CaseUnsupportedException
8388
*/
8489
public function getTo(DateTimeZone $dateTimeZoneOutput = new DateTimeZone(Timezones::UTC)): DateTime|null
8590
{
@@ -91,6 +96,7 @@ public function getTo(DateTimeZone $dateTimeZoneOutput = new DateTimeZone(Timezo
9196
*
9297
* @param DateTimeZone $dateTimeZoneOutput
9398
* @return DateTimeImmutable|null
99+
* @throws CaseUnsupportedException
94100
*/
95101
public function getFromImmutable(DateTimeZone $dateTimeZoneOutput = new DateTimeZone(Timezones::UTC)): DateTimeImmutable|null
96102
{
@@ -102,6 +108,7 @@ public function getFromImmutable(DateTimeZone $dateTimeZoneOutput = new DateTime
102108
*
103109
* @param DateTimeZone $dateTimeZoneOutput
104110
* @return DateTimeImmutable|null
111+
* @throws CaseUnsupportedException
105112
*/
106113
public function getToImmutable(DateTimeZone $dateTimeZoneOutput = new DateTimeZone(Timezones::UTC)): DateTimeImmutable|null
107114
{

0 commit comments

Comments
 (0)