Skip to content

Releases: stevegrunwell/time-constants

Version 2.0.2

23 Aug 18:33
a06344a
Compare
Choose a tag to compare
  • Use the const keyword instead of define() for slight performance gains, easier readability, and better IDE interoperability. Props @ChadSikorra and @ramsey for the recommendation! (#23)

Version 2.0.1

22 Aug 21:06
de474c5
Compare
Choose a tag to compare
  • Now that constants are namespaced, remove the defined() checks and unnecessary multiplication in order to a) help IDEs and b) remove an (albeit tiny) level of overhead (#21)

Version 2.0.0

20 Aug 22:08
e6e7761
Compare
Choose a tag to compare

⚠️ 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).

  • Introduce a Makefile for running dev commands (#17)
  • Move the constants from the global namespace into the TimeConstants namespace (#18)
  • Switch from PHP-CS-Fixer to PHP_CodeSniffer with the PHPCompatibility ruleset (#19)
    • 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
    • With only one version of PHPUnit necessary, tests have been upgraded for PHPUnit 11.x

Breaking changes

This release moves the constants defined by this package from the global namespace into the TimeConstants namespace.

Your implementations of these constants can be updated in either of the following ways:

  1. Explicitly import the constant(s) being used:
    use const TimeConstants\HOUR_IN_SECONDS;
  2. Update references to use the constants new, fully-qualified names:
    - cache($key, $value, HOUR_IN_SECONDS);
    + cache($key, $value, \TimeConstants\HOUR_IN_SECONDS);

Temporary aliases to help with migration

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.

Either of the following approaches will ensure the aliased versions are loaded:

  1. (Preferred) Add the file to your composer.json file in the autoload.files array:
    "autoload": {
        "files": [
            "vendor/stevegrunwell/time-constants/src/GlobalAliases.php"
        ]
    }
  2. Explicitly requiring the file:
      require_once __DIR__ . '/vendor/autoload.php';
    + require_once __DIR__ . '/vendor/stevegrunwell/time-constants/src/GlobalAliases.php';

Please note that this GlobalAliases.php file will be removed in the next major release (e.g. v3.x) of this library.

Version 1.2.0

18 Dec 16:09
acf6ad0
Compare
Choose a tag to compare
  • Add the following multipliers to help with sub-second timings (#13):
    • MILLISECONDS_PER_SECOND (1,000ms/s)
    • MICROSECONDS_PER_SECOND (1,000,000µs/s)
    • NANOSECONDS_PER_SECOND (1,000,000,000ns/s)
    • PICOSECONDS_PER_SECOND (1,000,000,000,000ps/s)
  • Remove the composer.lock file, overhaul CI pipeline so tests can be run across all supported versions of PHP (#14, props @peter279k).
  • Define an archive.exclude section in composer.json (#15).

Version 1.1.2

19 Jan 03:02
a83fbc4
Compare
Choose a tag to compare
  • Add PHP 8 support in composer.json (#9)
  • Move from Travis CI to GitHub Actions (#10)
  • Rename master to main

Version 1.1.1

25 Nov 18:14
b9bfb7d
Compare
Choose a tag to compare
  • Fixed a copy+paste error in the comment for ONE_MINUTE.
  • Add namespacing to the tests, minimum PHP version to composer.json (#5, props @peter279k).
  • Added PHP 7.4 to the Travis CI build matrix.

Version 1.1.0

02 Jan 04:46
Compare
Choose a tag to compare
  • Addition of both ONE_SECOND and ONE_MINUTE, which are both equal to 1 (#2).
  • Conform to the PSR-2 coding standards (#3).
  • Adjustments to the PHPUnit and Travis CI configuration files.

Version 1.0.0

21 Mar 17:10
Compare
Choose a tag to compare

First release of the package, containing 11 constants:

Time based in seconds

  • MINUTE_IN_SECONDS (60 seconds)
  • HOUR_IN_SECONDS (3600 seconds)
  • DAY_IN_SECONDS (86,400 seconds)
  • WEEK_IN_SECONDS (604,800 seconds)
  • MONTH_IN_SECONDS (2,592,000 seconds)
  • YEAR_IN_SECONDS (31,536,000 seconds)

Time based in minutes

  • HOUR_IN_MINUTES (60 minutes)
  • DAY_IN_MINUTES (1,440 minutes)
  • WEEK_IN_MINUTES (10,080 minutes)
  • MONTH_IN_MINUTES (43,200 minutes)
  • YEAR_IN_MINUTES (525,600 minutes)