定制 antnavdev/recurrence 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

antnavdev/recurrence

最新稳定版本:v1.0.1

Composer 安装命令:

composer require antnavdev/recurrence

包简介

Evaluate whether a recurring rule string is due on a given date.

README 文档

README

Evaluate whether a recurring rule string is due on a given date. Pure PHP 8.2+, no framework dependencies.

Installation

composer require antnavdev/recurrence

Usage

use AntNavDev\Recurrence\Recurrence;
use Carbon\Carbon;

$recurrence = new Recurrence('weekly:mon,wed,fri');
$recurrence->isDueOn(Carbon::parse('2026-04-13')); // Monday → true
$recurrence->isDueOn(Carbon::parse('2026-04-14')); // Tuesday → false

For rules that require an anchor date (biweekly and interval), pass it as the second constructor argument:

$recurrence = new Recurrence('biweekly:mon', anchorDate: Carbon::parse('2025-01-06'));
$recurrence->isDueOn(Carbon::parse('2025-01-06')); // week 0 → true
$recurrence->isDueOn(Carbon::parse('2025-01-13')); // week 1 → false
$recurrence->isDueOn(Carbon::parse('2025-01-20')); // week 2 → true

$recurrence = new Recurrence('interval:7', anchorDate: Carbon::parse('2025-01-01'));
$recurrence->isDueOn(Carbon::parse('2025-01-01')); // day 0 → true
$recurrence->isDueOn(Carbon::parse('2025-01-08')); // day 7 → true
$recurrence->isDueOn(Carbon::parse('2025-01-09')); // day 8 → false

Rule format

Rule string Meaning
null Every day (same as daily)
daily Every day
weekly:mon,wed,fri Specific days of the week (lowercase 3-letter codes)
biweekly:mon Every other week on that day, anchored to anchorDate
monthly:15 The 15th of each month
monthly:last The last day of each month
interval:N Every N days from anchorDate (N < 1 is never due)

Valid day-of-week codes: mon, tue, wed, thu, fri, sat, sun.

Exceptions

  • AntNavDev\Recurrence\InvalidRuleException (extends \InvalidArgumentException) — thrown when the rule string cannot be parsed (e.g. whenever:tuesday, monthly:foo).
  • \LogicException — thrown when isDueOn() is called with a biweekly or interval rule but no anchorDate was provided.

Running tests

composer install
./vendor/bin/phpunit

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固