Skip to content

Commit 373ff1a

Browse files
committed
🚧 wip
Signed-off-by: otengkwame <developerkwame@gmail.com>
1 parent ac34043 commit 373ff1a

1 file changed

Lines changed: 8 additions & 46 deletions

File tree

Core/helpers/webby_helper.php

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,44 +1717,6 @@ function chunk_list(mixed $list, int $size): array
17171717
/* ------------------------------- Date | Time | Format Functions ---------------------------------*/
17181718

17191719
if (! function_exists('now')) {
1720-
// /**
1721-
// * Current timestamp
1722-
// *
1723-
// * @return string
1724-
// */
1725-
// function now(string|bool $format = true)
1726-
// {
1727-
// if ($format === true) {
1728-
// return NOW;
1729-
// }
1730-
1731-
// $now = new DateTime();
1732-
// return $now->format($format);
1733-
1734-
// }
1735-
1736-
// /**
1737-
// * Get the current date and time.
1738-
// *
1739-
// * @param string|bool $format The format string, or `true` to return a Unix timestamp.
1740-
// * @return int|DateTimeImmutable|string The Unix timestamp, an object, or a formatted string.
1741-
// */
1742-
// function now(string|bool $format = true): int|DateTimeImmutable|string
1743-
// {
1744-
// $now = new DateTimeImmutable('now');
1745-
1746-
// if ($format === true) {
1747-
// return $now->getTimestamp();
1748-
// }
1749-
1750-
// if (is_string($format)) {
1751-
// return $now->format($format);
1752-
// }
1753-
1754-
// // Default case: return the DateTimeImmutable object
1755-
// return $now;
1756-
// }
1757-
17581720
/**
17591721
* Get the current date and time, optionally adjusting for a timezone or returning a specific format.
17601722
*
@@ -1777,12 +1739,12 @@ function now(string|bool|null|array $param = null): int|DateTimeImmutable|string
17771739
try {
17781740
$dtz = new DateTimeZone($param);
17791741
$timezone = $param;
1780-
$currentDt = new DateTimeImmutable('now', $dtz);
1742+
$current_date = new DateTimeImmutable('now', $dtz);
17811743
// If the parameter was just a timezone string, return the object for that timezone
1782-
return $currentDt;
1744+
return $current_date;
17831745
} catch (Exception $e) {
17841746
// If it's not a valid timezone, assume it's a format string
1785-
// The current $timezone (PHP's default) will be used for the currentDt creation below
1747+
// The current $timezone (PHP's default) will be used for the current_date creation below
17861748
}
17871749
}
17881750

@@ -1799,26 +1761,26 @@ function now(string|bool|null|array $param = null): int|DateTimeImmutable|string
17991761
}
18001762

18011763
// Create the DateTimeImmutable object for the determined timezone
1802-
$currentDt = new DateTimeImmutable('now', new DateTimeZone($timezone));
1764+
$current_date = new DateTimeImmutable('now', new DateTimeZone($timezone));
18031765

18041766
// Handle return based on $param or array settings
18051767
if ($param === true || (is_array($param) && isset($param['timestamp']) && $param['timestamp'] === true)) {
18061768
// Return Unix timestamp
1807-
return $currentDt->getTimestamp();
1769+
return $current_date->getTimestamp();
18081770
}
18091771

18101772
if (is_string($param) && !empty($param) && is_valid_date_format($param)) {
18111773
// Return formatted string
1812-
return $currentDt->format($param);
1774+
return $current_date->format($param);
18131775
}
18141776

18151777
if (is_array($param) && isset($param['format']) && is_string($param['format'])) {
18161778
// Return formatted string from array
1817-
return $currentDt->format($param['format']);
1779+
return $current_date->format($param['format']);
18181780
}
18191781

18201782
// Default: return the DateTimeImmutable object
1821-
return $currentDt;
1783+
return $current_date;
18221784
}
18231785

18241786
// Helper function to loosely check if a string is a date format

0 commit comments

Comments
 (0)