Simple utility for testing dates against chainable rules.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/ManDate
tests
.gitignore
.travis.yml
LICENSE
README.md
composer.json
phpunit.xml.dist

README.md

ManDate

Simple utility for testing dates against chained rules.

Build Status

Installation

The recommended way to install ManDate is through Composer. Require the pierswarmers/mandate package into your composer.json file:

composer require "pierswarmers/mandate" dev-master

composer require "pierswarmers/mandate" dev-master

Or in your composer.json file:

{
    "require": {
        "pierswarmers/mandate": "dev-master"
    }
}

Usage

use ManDate\Mandate;
use ManDate\Rule\WeekdayRule;
use ManDate\Rule\DaytimeRule;
use ManDate\Rule\MorningRule;

$mandate = new Mandate();

$mandate
    ->andWhere(new WeekdayRule())
    ->andWhere(new DaytimeRule())
    ->andWhereNot(new MorningRule())
;

$date  = new \DateTime('2015-03-02 11:30', new \DateTimeZone('Australia/Sydney'));

if ($mandate->validate($date)) {
    echo 'It\'s a weekday afternoon!';
}

Rules

Rule Details
AfternoonRule Later than midday.
CollisionRule Collides with another date.
DaytimeRule After sunrise and before sunset.
MorningRule Earlier than midday.
NighttimeRule After sunset and before sunrise.
WeekdayRule Monday to Friday.
WeekendRule Saturday and Sunday.