You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+52Lines changed: 52 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,54 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
8
+
## [Version 2.0.0] — 2024-08-20
9
+
10
+
**⚠️ Please note:** this is a **major** release, as it contains a breaking change to how the constants are defined. An extra file has been included to help bridge the gap between versions if you wish to run version 2.x of this library without updating all references across your app(s).
11
+
12
+
* Introduce a Makefile for running dev commands ([#17])
13
+
* Move the constants from the global namespace into the `TimeConstants` namespace ([#18])
14
+
* Switch from PHP-CS-Fixer to PHP_CodeSniffer with the PHPCompatibility ruleset ([#19])
15
+
* With this change, we can run **one** version of PHPUnit in CI, using PHP_CodeSniffer to detect any backwards compatibility breaks with this (admittedly simply) library
16
+
* With only one version of PHPUnit necessary, tests have been upgraded for PHPUnit 11.x
17
+
18
+
### Breaking changes
19
+
20
+
This release moves the constants defined by this package from the global namespace into the `TimeConstants` namespace.
21
+
22
+
Your implementations of these constants can be updated in either of the following ways:
23
+
24
+
1. Explicitly import the constant(s) being used:
25
+
```php
26
+
use const TimeConstants\HOUR_IN_SECONDS;
27
+
```
28
+
2. Update references to use the constants new, fully-qualified names:
Alternatively, you may include the new `GlobalAliases.php` file as a short-term fix. This file will take the newly-namespaced constants and **also** define them in the global namespace.
37
+
38
+
Either of the following approaches will ensure the aliased versions are loaded:
39
+
40
+
1. (**Preferred**) Add the file to your `composer.json` file in the `autoload.files` array:
Instead of spending the time figuring out what `24 * 60 * 60` means (or the fact that `86400` is meant to be one day in seconds), **Time Constants** allows you to represent the time using an easy-to-understand PHP constant:
These constants may seem familiar to WordPress developers, as they're absolutely [inspired by WordPress' use of time constants](https://codex.wordpress.org/Easier_Expression_of_Time_Constants). This package goes a bit further, however, adding `*_IN_MINUTES` constants, for easier use with libraries like [Laravel's `Cache` facade](https://laravel.com/docs/master/cache#cache-usage).
@@ -46,6 +46,8 @@ The package has been configured to automatically expose the `constants.php` file
46
46
47
47
This is a list of all constants defined by this package, along with their values. Each constant is wrapped in a `if (! defined(...))` conditional, ensuring these constants can easily be redefined if necessary and won't conflict with existing constants.
48
48
49
+
As of version 2.0.0 of this library, all of these constants are defined in the `TimeConstants` namespace. If you are upgrading from version 1.x, [please see the 2.0.0 release notes for notes about migration](https://github.com/stevegrunwell/time-constants/releases/tag/v2.0.0).
50
+
49
51
> Please note that these constants are defined for convenience, and not necessarily for accuracy; all months are treated as 30 days, and years as 365 days. If you need support for leap years or more advanced measures of time, you might consider [PHP's `DateTime` class](http://php.net/manual/en/book.datetime.php) or [Nesbot's Carbon package](https://carbon.nesbot.com/docs/).
0 commit comments