omitobisam/carbonate
Composer 安装命令:
composer require omitobisam/carbonate
包简介
Carbonate, more muscle to Carbon datetime wrapper
README 文档
README
Carbonate - a muscle to PHP Carbon with Collections
- dev-master or bleeding edge
Installation
composer require omitobisam/carbonate
If the above does not work then simply include the latest release version as in:
composer require omitobisam/carbonate ^0.2.1
For the dev-master simply change the version to dev-master
Another option is to clone the dev-master branch and you can have the bleeding version
Requirements
Minimum: PHP 5.6.4
Usage:
$mydate = new Carbonate('2017-09-01');
$enddate = new Carbonate('2017-10-30);
Get WeekendDates within two dates
$result = $mydate->everyWeekendDays($enddate); // /* * Result - A collection of dates in the weekend */ // Illuminate\Support\Collection Object ( [items:protected] => Array ( [0] => Carbonate\Carbonate Object ( [date] => 2017-09-02 00:00:00.000000 [timezone_type] => 3 [timezone] => UTC ) [1] => Carbonate\Carbonate Object ( [date] => 2017-09-03 00:00:00.000000 [timezone_type] => 3 [timezone] => UTC ) [2] => Carbonate\Carbonate Object ( [date] => 2017-09-09 00:00:00.000000 [timezone_type] => 3 [timezone] => UTC ) .......
Collections method can be further used on the result e.g
// Verify if the last Carbon instance is actually weekend $mydate->everyWeekendDays($enddate)->last()->isWeekend();
The result of the operations is shown as transformed from Carbon/Carbonate object to string using stringify()
Carbonate::stringify($mydate->everyWeekendDays($enddate)); // /* * Result - A collection of dates in the weekends as string */ // Illuminate\Support\Collection Object ( [items:protected] => Array ( [0] => 2017-09-02 00:00:00 [1] => 2017-09-03 00:00:00 [2] => 2017-09-09 00:00:00 [3] => 2017-09-10 00:00:00 [4] => 2017-09-16 00:00:00 [5] => 2017-09-17 00:00:00 [6] => 2017-09-23 00:00:00 [7] => 2017-09-24 00:00:00 [8] => 2017-09-30 00:00:00 [9] => 2017-10-01 00:00:00 [10] => 2017-10-07 00:00:00 [11] => 2017-10-08 00:00:00 [12] => 2017-10-14 00:00:00 [13] => 2017-10-15 00:00:00 [14] => 2017-10-21 00:00:00 [15] => 2017-10-22 00:00:00 [16] => 2017-10-28 00:00:00 [17] => 2017-10-29 00:00:00 ) )
A string of dates can be converted whole into Carbonate/Carbon instances:
Carbonate::carbonate(['today', 'tomorrow', '2017-10-30']); Illuminate\Support\Collection Object ( [items:protected] => Array ( [0] => Carbonate\Carbonate Object ( [date] => 2017-10-21 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Berlin ) [1] => Carbonate\Carbonate Object ( [date] => 2017-10-22 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Berlin ) [2] => Carbonate\Carbonate Object ( [date] => 2017-10-30 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Berlin ) ) )
Other methods
$mydate->thisMonth(); $mydate->getDatesOfDaysInMonth(['Monday', 'Saturday']); $mydate->everyWeekDays(); $mydate->everyDay('Monday'); $mydate->random(2); $mydate->randomOne(); $mydate->anyMonday(); $mydate->anyTuesday(); $mydate->anyWednesday(); $mydate->anyThursday(); $mydate->anyFriday(); $mydate->anySaturday(); $mydate->anySunday(); $mydate->any(); $mydate->anyOne('Monday'); $mydate->stringify([Carbonate::now(), Carbonate::now()->addDay(1)]); $mydate->carbonate(['today', 'tomorrow']); $mydate->weekends(Carbonate::now()->addDay(7));
Info
Contributions
omitobisam/carbonate 适用场景与选型建议
omitobisam/carbonate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37 次下载、GitHub Stars 达 2, 最近一次更新时间为 2017 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「time」 「date」 「collection」 「carbon」 「carbonate」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 omitobisam/carbonate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 omitobisam/carbonate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 omitobisam/carbonate 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Tools to convert between .NET and PHP date formats
Adds the EDTF data type to Wikibase
This package provides type-safe extension of the laravel collection, forcing a single type of object.
A powerful event calendar Tool for Laravel's Nova 5.
Date component is a set of methods to help with the manipulation of dates.
Traits to build collections of specific objects
统计信息
- 总下载量: 37
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-07-08