Skip to content

Releases: Kdyby/DateTimeProvider

Stable version released

14 Feb 18:20
8ac8083
Compare
Choose a tag to compare

We've just released first stable version of the DateTimeProvider library.

Please refer to the documentation for more information.

Kdyby/DateTimeProvider, formerly Kdyby/Clock

06 Jun 21:23
e8e7999
Compare
Choose a tag to compare

First pre-release version of the Kdyby/DateTimeProvider, formerly Kdyby/Clock.

Original interface has been split into four simpler interfaces:

  • Kdyby\DateTimeProvider\DateTimeProviderInterface
    • provides current date & time
    • returns a DateTimeImmutable instance
  • Kdyby\DateTimeProvider\DateProviderInterface
    • provides current date
    • returns a DateTimeImmutable instance without date (as in, time will always be 00:00:00.000000)
  • Kdyby\DateTimeProvider\TimeProviderInterface
    • provides current time
    • returns a DateInterval instance containing hour, minute, second and microsecond
  • Kdyby\DateTimeProvider\DateTimeZoneProviderInterface
    • provides current time zone
    • returns a DateTimeZone instance, matching the time zone of current time

Providers have been reworked and implement all the above interfaces (don't rely on it, it's an implementation detail).
There are three of them:

  • Kdyby\DateTimeProvider\Provider\ConstantProvider
    • given a DateTimeImmutable instance, it will aways return the same time for every future call
    • useful for HTTP requests or when time should be kept same
  • Kdyby\DateTimeProvider\Provider\CurrentProvider
    • whenever asked for, it will return a current time obtained from the system
    • useful i.e. for long-running proceses or when time precision is required
  • Kdyby\DateTimeProvider\Provider\MutableProvider
    • same as constant provider, but the time prototype could be explicitly changed
    • useful for testing

And there is also a helper factory:

  • Kdyby\DateTimeProvider\Provider\ConstantProviderFactory
    • given a date & time as an object or integer, returns a ConstantProvider