Skip to content

Commit

Permalink
Merge pull request #21 from stevegrunwell/feature/skip-defined-and-math
Browse files Browse the repository at this point in the history
Skip defined() checks, unnecessary multiplication
  • Loading branch information
stevegrunwell authored Aug 22, 2024
2 parents e6e7761 + c648d34 commit 2e000ae
Showing 1 changed file with 74 additions and 74 deletions.
148 changes: 74 additions & 74 deletions src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,40 @@
* @link https://codex.wordpress.org/Easier_Expression_of_Time_Constants
*/

/* One second. */
if (!defined(__NAMESPACE__ . '\\ONE_SECOND')) {
define(__NAMESPACE__ . '\\ONE_SECOND', 1);
}

/* One minute = 60 seconds. */
if (!defined(__NAMESPACE__ . '\\MINUTE_IN_SECONDS')) {
define(__NAMESPACE__ . '\\MINUTE_IN_SECONDS', 60);
}

/* One hour = 60 minutes. */
if (!defined(__NAMESPACE__ . '\\HOUR_IN_SECONDS')) {
define(__NAMESPACE__ . '\\HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS);
}

/* One day = 24 hours. */
if (!defined(__NAMESPACE__ . '\\DAY_IN_SECONDS')) {
define(__NAMESPACE__ . '\\DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS);
}

/* One week = 7 days. */
if (!defined(__NAMESPACE__ . '\\WEEK_IN_SECONDS')) {
define(__NAMESPACE__ . '\\WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS);
}

/* For common usage, assume one month = 30 days. */
if (!defined(__NAMESPACE__ . '\\MONTH_IN_SECONDS')) {
define(__NAMESPACE__ . '\\MONTH_IN_SECONDS', 30 * DAY_IN_SECONDS);
}

/* For common usage, assume one year = 365 days. */
if (!defined(__NAMESPACE__ . '\\YEAR_IN_SECONDS')) {
define(__NAMESPACE__ . '\\YEAR_IN_SECONDS', 365 * DAY_IN_SECONDS);
}
/**
* One second.
*/
define(__NAMESPACE__ . '\\ONE_SECOND', 1);

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

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

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

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

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

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

/**
* Time based in minutes.
Expand All @@ -61,58 +61,58 @@
* constants provide similar functionality.
*/

/* One minute. */
if (!defined(__NAMESPACE__ . '\\ONE_MINUTE')) {
define(__NAMESPACE__ . '\\ONE_MINUTE', 1);
}
/**
* One minute.
*/
define(__NAMESPACE__ . '\\ONE_MINUTE', 1);

/* One hour = 60 minutes. */
if (!defined(__NAMESPACE__ . '\\HOUR_IN_MINUTES')) {
define(__NAMESPACE__ . '\\HOUR_IN_MINUTES', 60);
}
/**
* One hour is 60 minutes.
*/
define(__NAMESPACE__ . '\\HOUR_IN_MINUTES', 60);

/* One day = 24 hours. */
if (!defined(__NAMESPACE__ . '\\DAY_IN_MINUTES')) {
define(__NAMESPACE__ . '\\DAY_IN_MINUTES', 24 * HOUR_IN_MINUTES);
}
/**
* One day is 24 hours.
*/
define(__NAMESPACE__ . '\\DAY_IN_MINUTES', 1440);

/* One week = 7 days. */
if (!defined(__NAMESPACE__ . '\\WEEK_IN_MINUTES')) {
define(__NAMESPACE__ . '\\WEEK_IN_MINUTES', 7 * DAY_IN_MINUTES);
}
/**
* One week is 7 days.
*/
define(__NAMESPACE__ . '\\WEEK_IN_MINUTES', 10080);

/* For common usage, assume one month = 30 days. */
if (!defined(__NAMESPACE__ . '\\MONTH_IN_MINUTES')) {
define(__NAMESPACE__ . '\\MONTH_IN_MINUTES', 30 * DAY_IN_MINUTES);
}
/**
* For general purposes, assume that one month is 30 days.
*/
define(__NAMESPACE__ . '\\MONTH_IN_MINUTES', 43200);

/* For common usage, assume one year = 365 days. */
if (!defined(__NAMESPACE__ . '\\YEAR_IN_MINUTES')) {
define(__NAMESPACE__ . '\\YEAR_IN_MINUTES', 365 * DAY_IN_MINUTES);
}
/**
* For general purposes, assume that one year is 365 days.
*/
define(__NAMESPACE__ . '\\YEAR_IN_MINUTES', 525600);

/**
* Common multipliers.
*
* These are useful when dealing with timing and things like cache expirations.
*/

/* A millisecond is 1/1000 of a second. */
if (!defined(__NAMESPACE__ . '\\MILLISECONDS_PER_SECOND')) {
define(__NAMESPACE__ . '\\MILLISECONDS_PER_SECOND', 1000);
}
/**
* A millisecond is 1/1000 of a second.
*/
define(__NAMESPACE__ . '\\MILLISECONDS_PER_SECOND', 1000);

/* A microsecond is one millionth of a second. */
if (!defined(__NAMESPACE__ . '\\MICROSECONDS_PER_SECOND')) {
define(__NAMESPACE__ . '\\MICROSECONDS_PER_SECOND', 1000000);
}
/**
* A microsecond is one millionth of a second.
*/
define(__NAMESPACE__ . '\\MICROSECONDS_PER_SECOND', 1000000);

/* A nanosecond is one billionth of a second. */
if (!defined(__NAMESPACE__ . '\\NANOSECONDS_PER_SECOND')) {
define(__NAMESPACE__ . '\\NANOSECONDS_PER_SECOND', 1000000000);
}
/**
* A nanosecond is one billionth of a second.
*/
define(__NAMESPACE__ . '\\NANOSECONDS_PER_SECOND', 1000000000);

/* A picosecond is one trillionth of a second. */
if (!defined(__NAMESPACE__ . '\\PICOSECONDS_PER_SECOND')) {
define(__NAMESPACE__ . '\\PICOSECONDS_PER_SECOND', 1000000000000);
}
/**
* A picosecond is one trillionth of a second.
*/
define(__NAMESPACE__ . '\\PICOSECONDS_PER_SECOND', 1000000000000);

0 comments on commit 2e000ae

Please sign in to comment.