承接 vamsiikrishna/when 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vamsiikrishna/when

Composer 安装命令:

composer require vamsiikrishna/when

包简介

Date/Calendar recursion library

README 文档

README

##When Date/Calendar recursion library for PHP 5.2+

Author: Thomas Planer

###About After a comprehensive search I couldn't find a PHP library which could handle recursive dates. There is: http://phpicalendar.org/ however it would have been extremely difficult to extract the recursion portion of the script from the application.

Oddly, there are extremely good date recursion libraries for both Ruby and Python:

Ruby: http://github.com/seejohnrun/ice_cube

Python: http://labix.org/python-dateutil

Since I couldn't find an equivalent for PHP I created When.

###Unit Tests

Tests were written in PHPUnit (http://www.phpunit.de/)

Initial set of tests were created from the examples found within RFC5545 (http://tools.ietf.org/html/rfc5545).

###Documentation

Initializing the class

$when = new When();

Once you have initialized the class you can create a recurring event by calling on the recur method

$when->recur(<DateTime object|valid Date string>, <yearly|monthly|weekly|daily>);

You can limit the number of dates to find by specifying a limit():

$when->limit(<int>);

Alternatively you can specify an end date:

$when->until(<DateTime object|valid Date String>);

Note: the end date does not have to match the recurring pattern.

Note: the script will stop returning results when either the limit or the end date is met.

More documentation to come, please take a look at the unit tests for an understanding of what the class is capable of.

###Examples (take a look at the unit tests for more examples)

The next 5 occurrences of Friday the 13th:

$r = new When();
$r->recur(new DateTime(), 'monthly')
  ->count(5)
  ->byday(array('FR'))
  ->bymonthday(array(13));

while($result = $r->next())
{
	echo $result->format('c') . '<br />';
}

Every four years, the first Tuesday after a Monday in November, for the next 20 years (U.S. Presidential Election day):

// this is the next election date
$start = new DateTime('2012-09-06');

$r = new When();
$r->recur($start, 'yearly')
  ->until($start->modify('+20 years'))
  ->interval(4)
  ->bymonth(array(11))
  ->byday(array('TU'))
  ->bymonthday(array(2,3,4,5,6,7,8));

while($result = $r->next())
{
	echo $result->format('c') . '<br />';
}

You can now pass raw RRULE's to the class:

$r = new When();
$r->recur('19970922T090000')->rrule('FREQ=MONTHLY;COUNT=6;BYDAY=-2MO');

while($result = $r->next())
{
	echo $result->format('c') . '<br />';
}

Warnings:

  • If you submit a pattern which has no results the script will loop infinitely.
  • If you do not specify an end date (until) or a count for your pattern you must limit the number of results within your script to avoid an infinite loop.

###Contributing

If you would like to contribute please create a fork and upon making changes submit a pull request.

Please ensure 100% pass of unit tests before submitting a pull request.

There are 78 tests, 1410 assertions currently.

>>>phpunit --verbose tests
PHPUnit 3.4.15 by Sebastian Bergmann.

tests
 When_Core_Tests
 ..

 When_Daily_Rrule_Test
 .....

 When_Daily_Test
 .....

 When_Iterator_Tests
 ..

 When_Monthly_Rrule_Test
 ..............

 When_Monthly_Test
 ..............

 When_Weekly_Rrule_Test
 ........

 When_Weekly_Test
 ........

 When_Rrule_Test
 ..........

 When_Yearly_Test
 ..........

Time: 2 seconds, Memory: 6.00Mb

OK (78 tests, 1410 assertions)

###License

Copyright (c) 2010 Thomas Planer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

vamsiikrishna/when 适用场景与选型建议

vamsiikrishna/when 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 57 次下载、GitHub Stars 达 9, 最近一次更新时间为 2013 年 01 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「date」 「calendar」 「recursion」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 vamsiikrishna/when 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 vamsiikrishna/when 我们能提供哪些服务?
定制开发 / 二次开发

基于 vamsiikrishna/when 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 57
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2013-01-25