Open dereuromark opened 8 months ago
I sth like this viable? https://github.com/cakephp/chronos/compare/2.x...2.x-interval
I have the same issue when trying to actually create any kind of improved wrapper around it. Maybe instead of extending it, we could encapsulate it using the proxy pattern?
Given how thorny datetime
can be, I think the proxy/decorator pattern is the only good option we have. We could include a toNative()
or toDateInterval
method so that working with other libraries is reasonable.
Downside is that the types on methods wouldnt work, if something expects a native one.
Downside is that the types on methods wouldnt work, if something expects a native one.
Which is why we'd have a toNative()
type method to provide compatibility with non-application code.
Why is that? The suggested method doesnt exist in the code
I would recommend we keep this method as it is useful and better than using the native DateInternal class and its methods. E.g. (string) casting to the native format is super important IMO.
I see that https://github.com/cakephp/chronos/commit/3449ecabecd5f029bec3342376b6a4c788b227f8 dropped it as there were some issues with the native class and compatibility.
I have the same issue when trying to actually create any kind of improved wrapper around it. Maybe instead of extending it, we could encapsulate it using the proxy pattern?
But according to e.g. https://github.com/pauci/datetime/blob/master/src/DateInterval.php it should work with extension.