Hello,
I would like to propose standardizing a clock interface for reading the
current time, date, timestamp, and timezone.
The problems I hope to solve is when testing time sensitive code, there is
a unified way to represend the current time. I have run into several issues
doing this some of which are:
- Some library use different Clock interfaces / implementations.
- Its impossible to mock some calls to date and time without using a PHP
extension to override the current time & date.
- There are about 10 competing library implentations to this problem just
from a quck search on packagist
The proposed interface would look like this:
interface ClockInterface
{
public function timestamp():int;
public function immutable():\DateTimeImmutable;
public function datetime():\DateTime
public function microtime():float
public function timezone():\DateTimeZone
}
I have created a pull request for this here:
https://github.com/php-fig/fig-standards/pull/1224
I am looking to find out if anyone is interesting in sponsoring this
Standard.
I have enjoyed using the PSR-16 interopable caches, and also migrated a
large legacy application to use PSR-7/PSR-15 and also benefits from using
standard middlewares and request extensions, and hope this could provide a
similar experience in the future.
Regards,
Chris Seufert
--
You received this message because you are subscribed to the Google Groups "PHP
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/php-fig/7c04c7b8-3d14-4261-881e-059b0268f14fn%40googlegroups.com.