> I also don't understand what you're trying to say. You can't round trip 
> every interval as encoded in a DateInterval object through an ISO 
> interval string, so we shouldn't attempt to do that.


I think you do know what I’m trying to say, but choose to disagree with me. ISO 
interval strings allow to express arbitrary intervals of time as a string, so I 
don’t know what possible intervals you’re referring to that purportedly cannot 
be encoded as an interval string.
If this still revolves around relative intervals, then I don’t see your point 
either. The ISO interval specification is the most appropriate serialization 
format for time intervals as it is commonly used and well understood. By 
choosing to serialize something like „next week“ to an ISO interval, I’m 
willingly accepting the conversion to an absolute amount of time. If the 
specific start and end dates are relevant for the use case, an interval is not 
the appropriate tool, but keeping both dates is.
Having a constructor that only accepts an ISO interval but no way to serialize 
the duration object back to an interval seems just like an inconsistent API to 
me. I’m not particularly attached to using `__toString()`, something like 
`toIsoInterval` or similar would do just as well. The only thing that annoys me 
here is a one-way parser for interval specs, deferring the serialization to 
userland PHP. 


Regards,
Moritz
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to