Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date-time from Docker does not conform to format #4

Open
Rid opened this issue Feb 14, 2023 · 1 comment
Open

date-time from Docker does not conform to format #4

Rid opened this issue Feb 14, 2023 · 1 comment

Comments

@Rid
Copy link
Member

Rid commented Feb 14, 2023

$object->setStart(\DateTime::createFromFormat('Y-m-d\\TH:i:sP', $data['Start']));

Here docker outputs:

      "Health": {
        "Status": "healthy",
        "FailingStreak": 0,
        "Log": [
          {
            "Start": "2023-02-14T16:56:23.106704411+01:00",
            "End": "2023-02-14T16:56:23.446917777+01:00",
            "ExitCode": 0,
            "Output": "somelog"
            },
         ]
       }

Notice the microseconds has 9 digits.

Even parsing this with "Y-m-d\TH:i:s.uP" gives false as u in php can only have a max of 6 digits.

php > var_dump(\DateTime::createFromFormat('Y-m-d\TH:i:s.uP', "2023-02-14T17:00:29.14396576+01:00"));
php shell code:1:
bool(false)

To make it work we could parse it with uu, but of course it's not correct, but it does dismiss the errors:

php > var_dump(\DateTime::createFromFormat('Y-m-d\TH:i:s.uuP', "2023-02-14T17:00:29.14396576+01:00"));
php shell code:1:
class DateTime#1 (3) {
  public $date =>
  string(26) "2023-02-14 17:00:29.760000"
  public $timezone_type =>
  int(1)
  public $timezone =>
  string(6) "+01:00"
}

I know this is generated by janephp, but it's a very specific case.

@Rid
Copy link
Member Author

Rid commented Oct 10, 2023

This is fixed here by: 0f3d8a7

Upstream janephp issue: janephp/janephp#752

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant