diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-10-11 21:11:10 -0400 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-10-11 21:11:10 -0400 |
commit | acba6839a6082e3e3800a733f8baea7c843fc02e (patch) | |
tree | e2847dcd13d9ccc3d8f0f6f936a5776df852e11b /app/Model/DateParser.php | |
parent | a8418afdebe92dde495bc5010645779c73939b7b (diff) |
Add 3 new fields for tasks: start date, time estimated and time spent
Diffstat (limited to 'app/Model/DateParser.php')
-rw-r--r-- | app/Model/DateParser.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/app/Model/DateParser.php b/app/Model/DateParser.php index 88e67686..38265f98 100644 --- a/app/Model/DateParser.php +++ b/app/Model/DateParser.php @@ -97,4 +97,46 @@ class DateParser extends Base { return mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp)); } + + /** + * Format date (form display) + * + * @access public + * @param array $values Database values + * @param array $fields Date fields + * @param string $format Date format + */ + public function format(array &$values, array $fields, $format = '') + { + if ($format === '') { + $format = $this->config->get('application_date_format'); + } + + foreach ($fields as $field) { + + if (! empty($values[$field])) { + $values[$field] = date($format, $values[$field]); + } + else { + $values[$field] = ''; + } + } + } + + /** + * Convert date (form input data) + * + * @access public + * @param array $values Database values + * @param array $fields Date fields + */ + public function convert(array &$values, array $fields) + { + foreach ($fields as $field) { + + if (! empty($values[$field]) && ! is_numeric($values[$field])) { + $values[$field] = $this->getTimestamp($values[$field]); + } + } + } } |