Skip to content

Commit

Permalink
Merge pull request #24 from stevegrunwell/release/v2.0.2
Browse files Browse the repository at this point in the history
Version 2.0.2
  • Loading branch information
stevegrunwell authored Aug 23, 2024
2 parents de474c5 + 20dd772 commit a06344a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Version 2.0.2] — 2024-08-23

* 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] — 2024-08-22

* 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])
Expand Down Expand Up @@ -103,6 +107,7 @@ Initial public release of the library, with the following constants:


[Unreleased]: https://github.com/stevegrunwell/time-constants/compare/main...develop
[Version 2.0.2]: https://github.com/stevegrunwell/time-constants/releases/tag/v2.0.2
[Version 2.0.1]: https://github.com/stevegrunwell/time-constants/releases/tag/v2.0.1
[Version 2.0.0]: https://github.com/stevegrunwell/time-constants/releases/tag/v2.0.0
[Version 1.2.0]: https://github.com/stevegrunwell/time-constants/releases/tag/v1.2.0
Expand All @@ -122,3 +127,4 @@ Initial public release of the library, with the following constants:
[#18]: https://github.com/stevegrunwell/time-constants/pull/18
[#19]: https://github.com/stevegrunwell/time-constants/pull/19
[#21]: https://github.com/stevegrunwell/time-constants/pull/21
[#23]: https://github.com/stevegrunwell/time-constants/pull/23
36 changes: 18 additions & 18 deletions src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Defines useful time-based constants.
*
* @package SteveGrunwell\TimeConstants
* @package TimeConstants
*/

declare(strict_types=1);
Expand All @@ -22,37 +22,37 @@
/**
* One second.
*/
define(__NAMESPACE__ . '\\ONE_SECOND', 1);
const ONE_SECOND = 1;

/**
* One minute is 60 seconds.
*/
define(__NAMESPACE__ . '\\MINUTE_IN_SECONDS', 60);
const MINUTE_IN_SECONDS = 60;

/**
* One hour is 60 minutes.
*/
define(__NAMESPACE__ . '\\HOUR_IN_SECONDS', 3600);
const HOUR_IN_SECONDS = 3600;

/**
* One day is 24 hours.
*/
define(__NAMESPACE__ . '\\DAY_IN_SECONDS', 86400);
const DAY_IN_SECONDS = 86400;

/**
* One week is 7 days.
*/
define(__NAMESPACE__ . '\\WEEK_IN_SECONDS', 604800);
const WEEK_IN_SECONDS = 604800;

/**
* For general purposes, assume that one month is 30 days.
*/
define(__NAMESPACE__ . '\\MONTH_IN_SECONDS', 2592000);
const MONTH_IN_SECONDS = 2592000;

/**
* For general purposes, assume that one year is 365 days.
*/
define(__NAMESPACE__ . '\\YEAR_IN_SECONDS', 31536000);
const YEAR_IN_SECONDS = 31536000;

/**
* Time based in minutes.
Expand All @@ -64,32 +64,32 @@
/**
* One minute.
*/
define(__NAMESPACE__ . '\\ONE_MINUTE', 1);
const ONE_MINUTE = 1;

/**
* One hour is 60 minutes.
*/
define(__NAMESPACE__ . '\\HOUR_IN_MINUTES', 60);
const HOUR_IN_MINUTES = 60;

/**
* One day is 24 hours.
*/
define(__NAMESPACE__ . '\\DAY_IN_MINUTES', 1440);
const DAY_IN_MINUTES = 1440;

/**
* One week is 7 days.
*/
define(__NAMESPACE__ . '\\WEEK_IN_MINUTES', 10080);
const WEEK_IN_MINUTES = 10080;

/**
* For general purposes, assume that one month is 30 days.
*/
define(__NAMESPACE__ . '\\MONTH_IN_MINUTES', 43200);
const MONTH_IN_MINUTES = 43200;

/**
* For general purposes, assume that one year is 365 days.
*/
define(__NAMESPACE__ . '\\YEAR_IN_MINUTES', 525600);
const YEAR_IN_MINUTES = 525600;

/**
* Common multipliers.
Expand All @@ -100,19 +100,19 @@
/**
* A millisecond is 1/1000 of a second.
*/
define(__NAMESPACE__ . '\\MILLISECONDS_PER_SECOND', 1000);
const MILLISECONDS_PER_SECOND = 1000;

/**
* A microsecond is one millionth of a second.
*/
define(__NAMESPACE__ . '\\MICROSECONDS_PER_SECOND', 1000000);
const MICROSECONDS_PER_SECOND = 1000000;

/**
* A nanosecond is one billionth of a second.
*/
define(__NAMESPACE__ . '\\NANOSECONDS_PER_SECOND', 1000000000);
const NANOSECONDS_PER_SECOND = 1000000000;

/**
* A picosecond is one trillionth of a second.
*/
define(__NAMESPACE__ . '\\PICOSECONDS_PER_SECOND', 1000000000000);
const PICOSECONDS_PER_SECOND = 1000000000000;
2 changes: 1 addition & 1 deletion src/GlobalAliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* either load this file via `autoload.files` in your `composer.json` file or by requiring the file
* directly in your code.
*
* @package SteveGrunwell\TimeConstants
* @package TimeConstants
*/

declare(strict_types=1);
Expand Down
2 changes: 1 addition & 1 deletion tests/ConstantsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* Tests the definition of time constants.
*
* @package SteveGrunwell\TimeConstants
* @package TimeConstants
*/
class ConstantsTest extends TestCase
{
Expand Down

0 comments on commit a06344a

Please sign in to comment.