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

DateTime format and control characters #94

Closed
seiffert opened this issue May 18, 2013 · 2 comments
Closed

DateTime format and control characters #94

seiffert opened this issue May 18, 2013 · 2 comments

Comments

@seiffert
Copy link

When using control characters like "!" in the format strings of DateTime-properties, this works just fine for deserialization, but does not for serialization. This is of course an issue with PHP's APIs and the incompatibility of format strings accepted by DateTime::format($format) and the ones accepted by DateTime::createFromFormat($format, $time). However, when using it with the serializer, this becomes an issue because there is (afaik) no way to define a separate deserialization type for a property.

Example:
Deserializing the value "2013-05-18" with type DateTime<'!Y-m-d'>, results in the following object:

DateTime Object
(
    [date] => 2013-05-18 00:00:00
    [timezone_type] => 3
    [timezone] => UTC
)

When serializing this object using the exact same type definition, this results in the string "!2013-05-18" (with the "!" as part of the result string, which is of course logical, but not intended).

Do you think, that there is a good way to circumvent this issue? If we can find one, I'd be happy to contribute by submitting a PR for it.

@AlexeyKosov
Copy link

AlexeyKosov commented Oct 13, 2016

Encountered the same issue. Still no solution for that?
I even can't override serializeDateTime method without copying the whole class since it uses private methods for some reasons.

@goetas
Copy link
Collaborator

goetas commented Jun 23, 2017

solved with #788

@goetas goetas closed this as completed Jun 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants