summaryrefslogtreecommitdiff
path: root/models/base.php
diff options
context:
space:
mode:
authorFrédéric Guillot <contact@fredericguillot.com>2014-03-05 22:27:48 -0500
committerFrédéric Guillot <contact@fredericguillot.com>2014-03-05 22:27:48 -0500
commit544f9924241f9b2caaf83ead203161ea41e5f1cf (patch)
treedcb5ba8a202fee673e395184795f570fd7c905ae /models/base.php
parent1e994f34486da72662ff39f1c3e130e4480e30ab (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.php18
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;
+ }
}