morebec/orkestra-datetime
Composer 安装命令:
composer require morebec/orkestra-datetime
包简介
Extension of CakePHP/Chronos that adds utility functions around DateTime manipulation.
README 文档
README
The Orkestra DateTime Component builds on top of cakephp/chronos which itself builds on top of
nesbot/carbon in order to bring immutability to dates and times as the default.
It provides the concept of a ClockInterface to be used in projects to get the time as an infrastructure concern
instead of directly accessing time as well as providing Date(Time)Range implementations.
Installation
composer require morebec/orkestra-orkestra-datetime
Then ensure the composer autoloader is imported:
<?php require 'vendor/autoload.php'; use Morebec\Orkestra\DateTime\ClockInterface; use Morebec\Orkestra\DateTime\SystemClock; /** @var ClockInterface $clock */ $clock = new SystemClock(); printf("Now: %s", $clock->now());
Usage
ClockInterface
The clock interface is used in order to centralize the location where the current date/time is fetched.
In essence, doing things like DateTime::now() in arbitrary locations of the code makes it harder to test, and manipulate.
Being an infrastructure related concept, it makes more sense to obtain the time from a Clock than being able to access
it from anywhere.
This can allow to test the system in the past or future.
Here are the implementations of the ClockInterface:
SystemClockImplementation of the system clock based on the time of the system.FixedClockImplementation of clock always returning the same fixed date time, to be used in unit tests for better control of time.OffsetClockClock that returns the date time from a specific defined offset at creation as if it were the current time. This is useful when we have to reverse in time or fast-forward in the future but still keep the clock running as the actual time passes.
For more information on the available functions of Date and DateTime, please refer to the documentation of cakephp/chronos.
morebec/orkestra-datetime 适用场景与选型建议
morebec/orkestra-datetime 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 568 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 04 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 morebec/orkestra-datetime 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 morebec/orkestra-datetime 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 568
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 7
- 依赖项目数: 10
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2021-04-21