jpmurray/laravel-rrule

此包已被废弃,不再维护。未建议替代包。

一款友好的Laravel包,用于管理日期重复规则

3.2.1 2016-08-23 19:23 UTC

This package is auto-updated.

Last update: 2022-02-01 13:00:31 UTC


README

Latest Version on Packagist Software License StyleCI Total Downloads

一个简单的助手,用于更流畅地生成日期发生,使用simshaun/recurr

注意事项

这是我第一个包。我实际上是为了获得更多关于包的知识而构建了这个包。它可能有用,也可能没有。它的结构可能很糟糕,也可能不糟糕。坦白说,我会努力维护和改进它,但请原谅我,因为这个包更多地是为了学习而构建的,而不是为了成为一个完美的包。

关于这一点:欢迎提交PR!

路线图

查看问题中的此标签

安装

通过Composer

$ composer require jpmurray/laravel-rrule

用法

$recurrence = new Recurrence();

//of course, you can chain all those methods!
$recurrence->setFrequency('weekly'); // Either one of `yearly`, `monthly`, `weekly`, `daily`, `hourly`, `minutly`, `secondly`
$recurrence->setCount(20); // the number of occurences we want. Cannot be used with `setUntil()`
$recurrence->setInterval(1); // every Nth time
$recurrence->setStart(Carbon::parse('August 9th 2016 21:18:00')); // a carbon object for when to start the occurences
$recurrence->setEnd(Carbon::parse('August 9th 2016 22:00:10')); // a carbon object for when to end the occurences
$recurrence->setDays([
	['sunday', null],
	['tuesday', -2],
	['friday', 3],
]); // the first is the day of the occurence, the other is the position (eg: -2: second to last; 3: third; null: not set)
$recurrence->setMonths([
	'january', 'march', 'october', 'december'
]); // months of the occurences
$recurrence->setLang('fr'); // for output to text. Defaults to english. Accepts ISO 639-1 language codes
$recurrence->setFrom(Carbon::now()->subMonth()); // calculate occurences from this date.
$recurrence->setUntil(Carbon::now()->addMonths(2)); // calculate occurences until this date. Cannot be used with `setCount()`
$recurrence->build(); //will save object and generate the outputs

以下方法不支持链式调用

$recurrence->getToText(); // returns the `toText` value of current rules. eg: "weekly in January, March, October and December on the Sunday, 2nd to the last Tuesday and 3rd Friday for 5 times"
$recurrence->getOccurences(); // returns a collection of Carbon object for each occurence with current rules

变更日志

有关最近更改的更多信息,请参阅CHANGELOG

测试

$ composer test

贡献

请参阅CONTRIBUTINGCONDUCT以获取详细信息。

安全

如果您发现任何安全相关的问题,请通过电子邮件himself@jpmurray.net联系,而不是使用问题跟踪器。

致谢

许可

MIT许可(MIT)。有关更多信息,请参阅许可文件