Skip to content

Commit 3a9ed0e

Browse files
authored
Merge pull request #6852 from ping-yee/refactor-replace-time-email
2 parents 11bb96b + d0f07df commit 3a9ed0e

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

deptrac.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ parameters:
162162
- Entity
163163
- Events
164164
Email:
165+
- I18n
165166
- Events
166167
Entity:
167168
- I18n

system/Email/Email.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace CodeIgniter\Email;
1313

1414
use CodeIgniter\Events\Events;
15+
use CodeIgniter\I18n\Time;
1516
use Config\Mimes;
1617
use ErrorException;
1718

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

20452046
break;

system/Helpers/date_helper.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111

1212
// CodeIgniter Date Helpers
1313

14+
use CodeIgniter\I18n\Time;
15+
1416
if (! function_exists('now')) {
1517
/**
1618
* Get "now" time
1719
*
18-
* Returns time() based on the timezone parameter or on the
20+
* Returns Time::now()->getTimestamp() based on the timezone parameter or on the
1921
* app_timezone() setting
2022
*
2123
* @param string $timezone
@@ -27,7 +29,7 @@ function now(?string $timezone = null): int
2729
$timezone = empty($timezone) ? app_timezone() : $timezone;
2830

2931
if ($timezone === 'local' || $timezone === date_default_timezone_get()) {
30-
return time();
32+
return Time::now()->getTimestamp();
3133
}
3234

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

0 commit comments

Comments
 (0)