Swader / diffbot-php-client

[Deprecated - Maintenance mode - use APIs directly please!] The official Diffbot client library
MIT License
53 stars 20 forks source link

Date enhancements #34

Closed Swader closed 8 years ago

Swader commented 8 years ago

The getDate and getEstimatedDate methods could use an upgrade.

The plan is to implement a DateObject with a __toString method to keep backwards compatibility, but to also add in some helper methods (perhaps via Carbon) that turn the Diffbot-returned string into something more useful in the current context. For example:

echo $article->getDate(); // "Wed, 18 Dec 2013 00:00:00 GMT" - as usual!
echo $article->getDate()->year; // 2013

Carbon's setToStringFormat will need to be used to set the format to Diffbot's default, to maintain BC, but other than that, Carbon can be plugged into the entity directly.

Wondering if we should make Carbon a recommendation only, and then crash the SDK if it's not installed an a Carbon method is used, or just force people to use Carbon...?