Skip to content

Commit

Permalink
Merge pull request #6852 from ping-yee/refactor-replace-time-email
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner committed Nov 14, 2022
2 parents 11bb96b + d0f07df commit 3a9ed0e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions deptrac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ parameters:
- Entity
- Events
Email:
- I18n
- Events
Entity:
- I18n
Expand Down
5 changes: 3 additions & 2 deletions system/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace CodeIgniter\Email;

use CodeIgniter\Events\Events;
use CodeIgniter\I18n\Time;
use Config\Mimes;
use ErrorException;

Expand Down Expand Up @@ -2038,8 +2039,8 @@ protected function sendData($data)
// See https://bugs.php.net/bug.php?id=39598 and http://php.net/manual/en/function.fwrite.php#96951
if ($result === 0) {
if ($timestamp === 0) {
$timestamp = time();
} elseif ($timestamp < (time() - $this->SMTPTimeout)) {
$timestamp = Time::now()->getTimestamp();
} elseif ($timestamp < (Time::now()->getTimestamp() - $this->SMTPTimeout)) {
$result = false;

break;
Expand Down
6 changes: 4 additions & 2 deletions system/Helpers/date_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@

// CodeIgniter Date Helpers

use CodeIgniter\I18n\Time;

if (! function_exists('now')) {
/**
* Get "now" time
*
* Returns time() based on the timezone parameter or on the
* Returns Time::now()->getTimestamp() based on the timezone parameter or on the
* app_timezone() setting
*
* @param string $timezone
Expand All @@ -27,7 +29,7 @@ function now(?string $timezone = null): int
$timezone = empty($timezone) ? app_timezone() : $timezone;

if ($timezone === 'local' || $timezone === date_default_timezone_get()) {
return time();
return Time::now()->getTimestamp();
}

$datetime = new DateTime('now', new DateTimeZone($timezone));
Expand Down

0 comments on commit 3a9ed0e

Please sign in to comment.