Last active
January 2, 2016 01:39
-
-
Save EHLOVader/8231572 to your computer and use it in GitHub Desktop.
PHP day class for managing a programmer's priorities.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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