arth / time-machine
当前日期时间的抽象
v2.0.0
2020-09-02 09:22 UTC
Requires (Dev)
- phpunit/php-code-coverage: ^6.0.7
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2024-08-29 04:37:24 UTC
README
测试目的下的应用时间控制模块。
用法
composer req arth/time-machine- 将所有
new DateTime('now')及其类似用法替换为Arth\Utils\TimeMachine::getInstance()->getNow() - 在测试中调用
Arth\Utils\TimeMachine::getInstance()->setNow($dt)并传入必要的 $dt 对象以实现时间偏移。
变更日志
v1.0.0
- getNow()/setNow(DateTimeInterface)
- setFreezedMode(bool) - getNow() 调用之间是否是时间滴答?
- date2ts(DateTimeInterface)/ts2date($ts) 正确处理微秒