|
16 | 16 | use CodeIgniter\Config\Factories; |
17 | 17 | use CodeIgniter\Database\SQLite3\Connection; |
18 | 18 | use CodeIgniter\Exceptions\RuntimeException; |
19 | | -use CodeIgniter\I18n\Time; |
20 | 19 | use CodeIgniter\Test\CIUnitTestCase; |
21 | 20 | use CodeIgniter\Test\DatabaseTestTrait; |
22 | 21 | use Config\Database; |
@@ -188,7 +187,7 @@ public function testTimezoneAutoSyncWithAppTimezone(): void |
188 | 187 |
|
189 | 188 | $appConfig = config('App'); |
190 | 189 | $appTimezone = $appConfig->appTimezone ?? 'UTC'; |
191 | | - $expectedOffset = $this->convertTimezoneToOffset($appTimezone); |
| 190 | + $expectedOffset = $this->getPrivateMethodInvoker($db, 'convertTimezoneToOffset')($appTimezone); |
192 | 191 |
|
193 | 192 | $this->assertSame($expectedOffset, $timezone); |
194 | 193 | } |
@@ -221,22 +220,4 @@ private function getDatabaseTimezone($db, string $driver): string |
221 | 220 | throw new RuntimeException("Unsupported driver: {$driver}"); |
222 | 221 | } |
223 | 222 | } |
224 | | - |
225 | | - /** |
226 | | - * Helper method to convert timezone to offset (mirrors BaseConnection logic) |
227 | | - */ |
228 | | - private function convertTimezoneToOffset(string $timezone): string |
229 | | - { |
230 | | - if (preg_match('/^[+-]\d{2}:\d{2}$/', $timezone)) { |
231 | | - return $timezone; |
232 | | - } |
233 | | - |
234 | | - $time = Time::now($timezone); |
235 | | - $offset = $time->getOffset(); |
236 | | - |
237 | | - $hours = (int) ($offset / 3600); |
238 | | - $minutes = abs((int) (($offset % 3600) / 60)); |
239 | | - |
240 | | - return sprintf('%+03d:%02d', $hours, $minutes); |
241 | | - } |
242 | 223 | } |
0 commit comments