celest-time / celest

Celest provides a alternative date and time API for PHP.
http://celest-time.org/
GNU General Public License v2.0
9 stars 1 forks source link

Implement JsonSerializable interface #3

Open MazeChaZer opened 7 years ago

MazeChaZer commented 7 years ago

Does it make sense for LocalDate, LocalDateTime, ... to implement the JsonSerializable PHP interface? That would ease the serialization of objects with date/time properties. I believe a sensible serialization strategy would be using the ISO DateTimeFormatters to turn the date/time objects into strings. If this is a feature that is wanted, I can prepare a pull request.

hanikesn commented 7 years ago

That makes sense. There's no deserialize counterpart, right? Also I would use the existing _toString function, which should do the right thing and is a bit more optimized than the generic formatter.

Also keep in mind that there's still an open TODO to finalize the PHP serialize/deserialize format.

MazeChaZer commented 7 years ago

Sounds good 👍 Yeah, AFAIK, there is no interface for JSON deserialization. I will start working on this.