Skip to content

Commit

Permalink
Make sure our formats are never empty
Browse files Browse the repository at this point in the history
This makes sure we always have something to render.

Fixes #170
  • Loading branch information
nitriques committed Jun 26, 2015
1 parent c8aeb2e commit 5c77032
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions fields/field.datetime.php
Expand Up @@ -684,6 +684,21 @@ public function prepareTextValue($data, $entry_id = null) {
return implode(', ', $this->prepareTextArray($data, $entry_id, false));
}

public function getScheme() {
$hasTime = (int)$this->get('time') === 1;
// Get schema
$scheme = trim($hasTime ? __SYM_DATETIME_FORMAT__ : __SYM_DATE_FORMAT__);
if (empty($scheme)) {
$scheme = $hasTime ? 'Y/m/d H:i:s' : 'Y/m/d';
}
return $scheme;
}

public function getTimeFormat() {
$timeFormat = trim(__SYM_TIME_FORMAT__);
return !empty($timeFormat) ? $timeFormat : 'H:i:s';
}

public function prepareTextArray($data, $entry_id, $html) {
if(!is_array($data['start'])) $data['start'] = array($data['start']);
if(!is_array($data['end'])) $data['end'] = array($data['end']);
Expand All @@ -692,16 +707,9 @@ public function prepareTextArray($data, $entry_id, $html) {
return array();
}

// Get schema
if((int)$this->get('time') === 1) {
$scheme = __SYM_DATETIME_FORMAT__;
}
else {
$scheme = __SYM_DATE_FORMAT__;
}
$scheme = $this->getScheme();

// Get timeformat
$timeFormat = Symphony::Configuration()->get('time_format', 'region');
$timeFormat = $this->getTimeFormat();

// Parse dates
$value = array();
Expand Down

0 comments on commit 5c77032

Please sign in to comment.