smhg/date-timespan 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

smhg/date-timespan

Composer 安装命令:

composer require smhg/date-timespan

包简介

Collection of PHP classes to work with timespans.

关键字:

README 文档

README

Collection of PHP classes to work with timespans.

It differs from DatePeriod in that it only defines a timespan/period by a start and end date. It offers algebraic methods to manipulate a timespan or a collection of them. Convert it to a DatePeriod passing a DateInterval to toPeriod() when you need to iterate over it.

Installation

$ composer require smhg/date-timespan

Methods

Timespan

use Timespan\Timespan;

$start = new DateTime('last monday');
$end = clone $start;
$end->modify('+1 week');

$timespan = new Timespan($start, $end);

contains(DateTime)

Returns whether the timespan contains a date.

overlaps(Timespan)

Returns whether the timespan overlaps with another timespan.

diff(Timespan)

Returns a collection of timespans (pieces of the original timespan) which do not appear in another timespan.

merge(Timespan)

Returns a collection with the merged timespan or both timespans when a merge was not possible.

trim(DateTime, DateTime)

Returns a new timespan fitting within the passed boundaries or null if no time remains.

compare(Timespan)

Returns whether the timespan occurs before, together or after another timespan.

toPeriod(DateInterval)

Converts the timespan to a DatePeriod using an interval.

__toString()

Converts the timespan to a string in ISO 8601 time interval format.

toArray()

Converts the timespan to an array with a single interval element containing the toString representation.

Collection

use Timespan\Timespan;
use Timespan\Collection;

$collection = new Collection();
$collection[] = new Timespan(...);

sort()

Sorts the collection based on the start of each timespan.

compress()

Joins timespans in the collection if they overlap. Also sorts the result.

merge()

Merges the collection with another collection. Also compresses the result.

统计信息

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

GitHub 信息

  • Stars: 6
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-03-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固