Skip to content

\Nette\Utils\DateTime::fromParts(2021,12,28) causing crash #248

@tprochazka

Description

@tprochazka

Nette version: 3.0.8
PHP: 7.2.11 (I did not test the newer version, but Nette has 7.2 as the minimum supported version)
Czech localization system and setlocale(LC_ALL, 'cs_CZ');

\Nette\Utils\DateTime::fromParts(2021,12,28)

End with this exception:
DateTime::__construct(): Failed to parse time string (2021-12-28 00:00:0,00000) at position 23 (0): Unexpected character

I tried to change line

$s = sprintf('%04d-%02d-%02d %02d:%02d:%02.5f', $year, $month, $day, $hour, $minute, $second);

to
$s = sprintf('%04d-%02d-%02d %02d:%02d:%02d', $year, $month, $day, $hour, $minute, $second);

And it works now.

Do we need microseconds there, if biggest possible entered value is 1s?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions