Skip to content

Commit

Permalink
feat: update dependencies (requires PHP8.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Dec 27, 2023
1 parent eabbe8b commit 488e689
Show file tree
Hide file tree
Showing 25 changed files with 380 additions and 163 deletions.
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
"matthiasmullie/minify": "^1.3",
"wa72/htmlpagedom": "^3.0",
"baumrock/humandates": "^1.0"
},
"config": {
"platform": {
"php": "8.1"
}
}
}
73 changes: 38 additions & 35 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 22 additions & 8 deletions vendor/baumrock/humandates/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,50 @@
## [1.0.4](https://github.com/baumrock/HumanDates/compare/v1.0.3...v1.0.4) (2023-06-13)
## [1.1.1](https://github.com/baumrock/HumanDates/compare/v1.1.0...v1.1.1) (2023-12-27)


### Bug Fixes

* composer autoload setup ([58c8a54](https://github.com/baumrock/HumanDates/commit/58c8a54ef277d31e2598e49eb233942fb09af8a0))
* remove comments ([c801aa1](https://github.com/baumrock/HumanDates/commit/c801aa1d0b740c63f11b0cfa6762248f4847ffdf))



## [1.0.3](https://github.com/baumrock/HumanDates/compare/v1.0.2...v1.0.3) (2023-06-13)
# [1.1.0](https://github.com/baumrock/HumanDates/compare/v1.0.4...v1.1.0) (2023-12-27)


### Bug Fixes

* add autoload for composer ([91daf67](https://github.com/baumrock/HumanDates/commit/91daf6780e9999143c6ed470515eac7977342acd))
* allow custom range patterns in `range` method ([b7a5e2b](https://github.com/baumrock/HumanDates/commit/b7a5e2b7d58255d36f9c6bd66ed952ef56d1a54b))


### Features

* add patterns parameter to range() as mentioned in readme ([bbf057d](https://github.com/baumrock/HumanDates/commit/bbf057d2bb02fa811ef7d435131120188316df44))

## [1.0.2](https://github.com/baumrock/HumanDates/compare/v1.0.1...v1.0.2) (2023-06-13)


## [1.0.4](https://github.com/baumrock/HumanDates/compare/v1.0.3...v1.0.4) (2023-06-13)


### Bug Fixes

* remove dots from default rangePatterns ([a9ec76e](https://github.com/baumrock/HumanDates/commit/a9ec76ebb4823dc2a23c08b51766d4ea6295317d))
* composer autoload setup ([58c8a54](https://github.com/baumrock/HumanDates/commit/58c8a54ef277d31e2598e49eb233942fb09af8a0))



## [1.0.1](https://github.com/baumrock/HumanDates/compare/46fd51855a0c09628cbc31f606998172bb54f8e7...v1.0.1) (2023-06-13)
## [1.0.3](https://github.com/baumrock/HumanDates/compare/v1.0.2...v1.0.3) (2023-06-13)


### Bug Fixes

* default patterns ([46fd518](https://github.com/baumrock/HumanDates/commit/46fd51855a0c09628cbc31f606998172bb54f8e7))
* add autoload for composer ([91daf67](https://github.com/baumrock/HumanDates/commit/91daf6780e9999143c6ed470515eac7977342acd))



## [1.0.2](https://github.com/baumrock/HumanDates/compare/v1.0.1...v1.0.2) (2023-06-13)


### Bug Fixes

* remove dots from default rangePatterns ([a9ec76e](https://github.com/baumrock/HumanDates/commit/a9ec76ebb4823dc2a23c08b51766d4ea6295317d))



27 changes: 24 additions & 3 deletions vendor/baumrock/humandates/HumanDates.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ function __construct(
$format = "d. MMM y",
$patterns = null,
) {
$this->setPatterns($patterns);
$this->setLocale($locale);
$this->setFormat($format);
$this->setPatterns($patterns);
}

/**
Expand Down Expand Up @@ -57,22 +57,43 @@ private function getString(int $timestamp, $pattern): string

/**
* Format a daterange as human readable date string
*
* Usage:
* echo $dates->range("2023-12-27", "2023-12-28");
*
* Usage with custom pattern:
* echo $dates->range("2023-12-27", "2023-12-28", [
* 'sameMonth' => ["d.", " until ", "d. MMM Y"],
* ]);
*
* Note: Setting a pattern for this request will not modify
* the globally set pattern. If you want to change the pattern globally
* use $dates->setPatterns(...)->range(...)
*/
function range($from, $to): string
function range($from, $to, array $patterns = []): string
{
$from = $this->timestamp($from);
$to = $this->timestamp($to);

// find out which pattern we want to use
if (date("Ymd", $from) === date("Ymd", $to)) $pattern = 'sameDay';
elseif (date("Ym", $from) === date("Ym", $to)) $pattern = 'sameMonth';
elseif (date("Y", $from) === date("Y", $to)) $pattern = 'sameYear';
else $pattern = 'default';

$pattern = $this->patterns[$pattern];
// merge patterns
// use global patterns by default and merge custom set patterns
// for this request without modifying the default patterns
$patterns = array_merge($this->patterns, $patterns);

// get the pattern for this range (eg for sameDay)
$pattern = $patterns[$pattern];
$pieces = array_filter([
$this->getString($from, $pattern[0]),
$this->getString($to, $pattern[2]),
]);

// return the final date range string
return implode($pattern[1], $pieces);
}

Expand Down
16 changes: 15 additions & 1 deletion vendor/baumrock/humandates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

HumanDates is a PHP library that provides convenient methods for formatting dates as human-readable strings and generating human-friendly date ranges. It uses the `IntlDateFormatter` class to ensure accurate localization and formatting based on the specified locale.

```html
<!-- before --> 1.1.2023 - 3.1.2023
<!-- after --> 1. - 3.1.2023
```

<img width="861" alt="image" src="https://github.com/baumrock/HumanDates/assets/8488586/59a2a9fb-a925-4c79-8d99-f199583a3bcc">


## Usage

To get started, include the HumanDates library and create a new instance:
Expand Down Expand Up @@ -80,6 +88,12 @@ echo $dates->range("2023-01-01", "2023-01-03", [
]);
```

Note that this will set the patterns for this single request only! If you want to modify the globally used patterns you can do this:

```php
echo $dates->setPatterns(...)->range(...);
```

## Setting Locales

You can set the locale for date formatting either globally for the current `HumanDates` instance or on a per-format basis.
Expand Down Expand Up @@ -113,4 +127,4 @@ echo $dates->format("2023-1-1", "d. MMMM y"); // Output: 1. Jänner 2023

## Star the Repository

If you find HumanDates useful or interesting, please star the repository on GitHub. By starring the repository, you show your appreciation and support for the project. It also helps us understand the level of community interest and motivates us to further improve the library. So, why not give us a star today?
If you find HumanDates useful or interesting, please star the repository on GitHub. By starring the repository, you show your appreciation and support for the project. It also helps us understand the level of community interest and motivates us to further improve the library. ⭐
2 changes: 1 addition & 1 deletion vendor/baumrock/humandates/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "1.0.4"
"version": "1.1.1"
}
5 changes: 2 additions & 3 deletions vendor/bin/latte-lint
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ if (PHP_VERSION_ID < 80000) {
(function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
|| (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper'))
) {
include("phpvfscomposer://" . __DIR__ . '/..'.'/latte/latte/bin/latte-lint');
exit(0);
return include("phpvfscomposer://" . __DIR__ . '/..'.'/latte/latte/bin/latte-lint');
}
}

include __DIR__ . '/..'.'/latte/latte/bin/latte-lint';
return include __DIR__ . '/..'.'/latte/latte/bin/latte-lint';
2 changes: 1 addition & 1 deletion vendor/composer/autoload_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$baseDir = dirname($vendorDir);

return array(
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
'f91de9311f7b320431569e8469ba6c76' => $vendorDir . '/baumrock/humandates/HumanDates.php',
);

0 comments on commit 488e689

Please sign in to comment.