diff options
author | Frédéric Guillot <contact@fredericguillot.com> | 2014-03-05 22:27:48 -0500 |
---|---|---|
committer | Frédéric Guillot <contact@fredericguillot.com> | 2014-03-05 22:27:48 -0500 |
commit | 544f9924241f9b2caaf83ead203161ea41e5f1cf (patch) | |
tree | dcb5ba8a202fee673e395184795f570fd7c905ae /models/base.php | |
parent | 1e994f34486da72662ff39f1c3e130e4480e30ab (diff) |
Add a 'due date' field and display the number of comments on the board
Diffstat (limited to 'models/base.php')
-rw-r--r-- | models/base.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/models/base.php b/models/base.php index 2ecf4280..95c5b07f 100644 --- a/models/base.php +++ b/models/base.php @@ -12,13 +12,14 @@ require __DIR__.'/../vendor/SimpleValidator/Validators/Integer.php'; require __DIR__.'/../vendor/SimpleValidator/Validators/Equals.php'; require __DIR__.'/../vendor/SimpleValidator/Validators/AlphaNumeric.php'; require __DIR__.'/../vendor/SimpleValidator/Validators/GreaterThan.php'; +require __DIR__.'/../vendor/SimpleValidator/Validators/Date.php'; require __DIR__.'/../vendor/PicoDb/Database.php'; require __DIR__.'/schema.php'; abstract class Base { const APP_VERSION = 'master'; - const DB_VERSION = 8; + const DB_VERSION = 9; private static $dbInstance = null; protected $db; @@ -59,4 +60,19 @@ abstract class Base return hash('crc32b', $token); } + + public function getTimestampFromDate($value, $format) + { + $date = \DateTime::createFromFormat($format, $value); + + if ($date !== false) { + $errors = \DateTime::getLastErrors(); + if ($errors['error_count'] === 0 && $errors['warning_count'] === 0) { + $timestamp = $date->getTimestamp(); + return $timestamp > 0 ? $timestamp : 0; + } + } + + return 0; + } } |