Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

Simple utility for testing dates against chainable rules.

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.