On Thu, Mar 4, 2021, at 6:34 AM, Chris Seufert wrote:
> 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

Have you spoken to the maintainers of those 10 competing libraries?  For a spec 
like this to be successful it would need buy-in from those implementers, 
otherwise we just end up with an XKCD 927 problem.  (https://xkcd.com/927/)  
They're the people that you'd want in a working group.

In related news, I'm -1 on anything that still uses DateTime.  
DateTimeImmutable or bust.

--Larry Garfield

-- 
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 php-fig+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/b3714d46-6502-463d-bc63-0c3301486a0b%40www.fastmail.com.

Reply via email to