arth/time-machine

Abstraction for current datetime

Installs: 143

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/arth/time-machine

v2.0.0 2020-09-02 09:22 UTC

This package is auto-updated.

Last update: 2025-09-29 02:42:09 UTC


README

Module for application time control for testing purpose.

Usage:

  • composer req arth/time-machine
  • replace all new DateTime('now') and analogues with Arth\Utils\TimeMachine::getInstance()->getNow()
  • in tests call Arth\Utils\TimeMachine::getInstance()->setNow($dt) with necessary $dt object for time shift.

Changelog

v1.0.0

  • getNow()/setNow(DateTimeInterface)
  • setFreezedMode(bool) - is time tick between getNow() calls?
  • date2ts(DateTimeInterface)/ts2date($ts) with correct microseconds handling