Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system/I18n/TimeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public static function createFromFormat($format, $datetime, $timezone = null): s
*/
public static function createFromTimestamp(float|int $timestamp, $timezone = null, ?string $locale = null): static
{
$time = new static(sprintf('@%.6f', $timestamp), 'UTC', $locale);
$time = new static(sprintf('@%.6F', $timestamp), 'UTC', $locale);

$timezone ??= 'UTC';

Expand Down
13 changes: 10 additions & 3 deletions tests/system/I18n/TimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,18 @@ public function testCreateFromTimestamp(): void
public function testCreateFromTimestampWithMicroseconds(): void
{
$timestamp = 1489762800.654321;
$locale = setlocale(LC_NUMERIC, '0');

// The timezone will be UTC if you don't specify.
$time = Time::createFromTimestamp($timestamp);
setlocale(LC_NUMERIC, 'de_DE.UTF-8', 'de_DE');

try {
// The timezone will be UTC if you don't specify.
$time = Time::createFromTimestamp($timestamp);

$this->assertSame('2017-03-17 15:00:00.654321', $time->format('Y-m-d H:i:s.u'));
$this->assertSame('2017-03-17 15:00:00.654321', $time->format('Y-m-d H:i:s.u'));
} finally {
setlocale(LC_NUMERIC, $locale);
}
}

public function testCreateFromTimestampWithTimezone(): void
Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/v4.7.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Bugs Fixed
- **Commands:** Fixed a bug in the ``env`` command where passing options only would cause the command to throw a ``TypeError`` instead of showing the current environment.
- **Common:** Fixed a bug where the ``command()`` helper function did not properly clean up output buffers, which could lead to risky tests when exceptions were thrown.
- **Kint:** Fixed a bug where stale Content Security Policy nonces were reused in worker mode, causing browser CSP violations for Debug Toolbar assets.
- **Time:** Fixed a bug where ``Time::createFromTimestamp()`` could fail for microsecond timestamps when ``LC_NUMERIC`` used a comma decimal separator.
- **Validation:** Fixed a bug where ``Validation::getValidated()`` dropped fields whose validated value was explicitly ``null``.

See the repo's
Expand Down
Loading