brick / date-time

Date and time library for PHP
MIT License
321 stars 29 forks source link

Discussion: ISO8601/RFC3339 time + timezone class #108

Open hendrikheil opened 1 month ago

hendrikheil commented 1 month ago

I recently needed timezone offsets for RFC3339 time strings (which are a bit more strict than ISO8601). The implementation heavily used already existing parsers and classes available in brick/date-time.

I'd love to contribute the code back upstream in case others find use. Especially since there doesn't seem to be any other widely used library for RFC3339 time parsing around in PHP. My use-case involved formatting and parsing for OAS 3.1 time formatted strings, which are RFC3339 full-time strings.

Before I actually open up a PR, I wanted to see if this is something that generally fits into the library?

I implemented it as a Time class which generally just holds a LocalTime and optional TimeZoneOffset with some comparison and formatting methods in it.

This does require a dedicated parser, but it's very simple and just re-uses existing patterns.

If this sounds useful, I'll work on a PR and send it here for discussion.

solodkiy commented 1 month ago

Could you show the code of this fork?