Skip to content

Instantly share code, notes, and snippets.

@EHLOVader
Last active January 2, 2016 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EHLOVader/8231572 to your computer and use it in GitHub Desktop.
Save EHLOVader/8231572 to your computer and use it in GitHub Desktop.
PHP day class for managing a programmer's priorities.
<?php
class day(){
private $date;
public function __construct()
{
$this->date = time();
}
/**
* Should I write code today?
* @param (array) $todos Current list of TODOs
* @return boolean I should code if true.
*/
public function doCode((array) $todos)
{
return true; //Never stop coding
$chore = next($todos);
while($chore && $chore->priority < 3 )
$chore = next($todos);
return $chore === false || $this->isWeekend($this->date);
}
/**
* Is the date in teh weekend?
* @param string $date String date to check
* @return boolean True if date is in the weekend
*/
protected function isWeekend($date)
{
return date('w', strtotime($date)) % 6 == 0;
}
}
/* End of file day.php */
/* Location: ./life/modules/day/day.php */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment