2017 © Pedro Peláez
 

library dateinterval

This class extends PHP's \DateInterval class providing weeks+days and negative spec support

image

ealore/dateinterval

This class extends PHP's \DateInterval class providing weeks+days and negative spec support

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

Ealore\DateInterval

This is an extension of PHP's \DateInterval with new methods and support for interval specification with both weeks and days at the same time, while in the standard implementation it's possible to use either., (*2)

Usage

<?php

use Ealore\DateInterval;

$interval = new DateInterval('P5W1D');
// with this implementation it is possible to specify both weeks and days in the same specification string

echo $interval->w; // outputs 5
echo $interval->d; // outputs 1

legacy() returns an instance compatible with PHP's \DateInterval

$legacy = $di->legacy();

echo $legacy->w; // outputs 0
echo $legacy->d; // outputs 36

getIntervalSpec() returns the interval specification string

$interval = new DateInterval('P5W1D');

echo $interval->getIntervalSpec(); // outputs P5W1D


$zero_interval = new DateInterval('P0D');

echo $interval->getIntervalSpec(); // outputs P0D

Installation

$ composer require ealore/dateinterval

Changelog

version 1.0.3 - added a check to avoid an 'unknown or bad format' exception, (*3)

version 1.0.2 - bugfix, (*4)

version 1.0.1 - added a check to getIntervalSpec(), (*5)

version 1.0, (*6)

  • added w property
  • added legacy() method to fetch an instance of PHP's \DateInterval
  • added getIntervalSpec() that returns the interval specification string. If the interval duration is 0, the original interval_spec is returned.

The Versions

21/03 2017

dev-master

9999999-dev

This class extends PHP's \DateInterval class providing weeks+days and negative spec support

  Sources   Download

MIT

The Development Requires

21/03 2017

1.0.4

1.0.4.0

This class extends PHP's \DateInterval class providing weeks+days and negative spec support

  Sources   Download

MIT

The Development Requires

09/03 2017

1.0.3

1.0.3.0

This class extends PHP's \DateInterval class providing weeks+days and negative spec support

  Sources   Download

MIT

The Development Requires

08/02 2017

1.0.2

1.0.2.0

This class extends PHP's \DateInterval class providing weeks+days and negative spec support

  Sources   Download

MIT

The Development Requires

08/02 2017

1.0.1

1.0.1.0

This class extends PHP's \DateInterval class providing weeks+days and negative spec support

  Sources   Download

MIT

The Development Requires

08/02 2017

1.0

1.0.0.0

This class extends PHP's \DateInterval class providing weeks+days and negative spec support

  Sources   Download

MIT

The Development Requires