2017 © Pedro Peláez
 

library day-of-week

Day of week library

image

hrevert/day-of-week

Day of week library

  • Thursday, November 20, 2014
  • by hrevert
  • Repository
  • 2 Watchers
  • 2 Stars
  • 23 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

day-of-week

Master Branch Build Status Latest Stable Version Total Downloads, (*1)

Day of week library, (*2)

Usage

Please read the docs of php-enum first., (*3)

use Hrevert\Day\Day;

/** @var Day */
$day = Day::get(Day::MONDAY);
// or $day = Day::MONDAY();
// or $day = Day::getByName('MONDAY');
// or $day = Day::getByOrdinal(1);  i.e. find by ISO-8601 numeric representation of day

/** @var Day */
$today = Day::getToday();
use Hrevert\Day\Day;
use Hrevert\Day\DayCollection;

$days = new DayCollection([Day::SUNDAY(), Day::MONDAY()]);

var_dump($days->contains(Day::SUNDAY())); // bool(true)
var_dump($days->contains(Day::MONDAY())); // bool(true)

$days->remove(Day::MONDAY());
var_dump($days->contains(Day::MONDAY())); // bool(false)

$days->add(Day::MONDAY());
var_dump($days->contains(Day::MONDAY())); // bool(true)

Since Hrevert\Day\DayCollection is just an extension of Doctrine\Common\Collections\ArrayCollection, it should not be so difficult., (*4)

Using in <select> element

use Hrevert\Day\Day;

echo '<select name="day">';
foreach (Day::getOptions() as $iso => $display) {
    echo '<option value="' . $iso . '">' . $display . '</option>';
}
echo '</select>';


// on form submit
/** @var Hrevert\Day\Day */
$day = Hrevert\Day\Day::get((int) $_POST['day']);

The Versions

20/11 2014

dev-master

9999999-dev https://github.com/hrevert/day-of-week

Day of week library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hrevert Technologies

datetime day hrevert day-of-week

17/07 2014

0.0.1

0.0.1.0 https://github.com/hrevert/day-of-week

Day of week library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hrevert Technologies

datetime day hrevert day-of-week