Permalink
Browse files

ID#255: added "Now" keyword for date range definition to ease form cr…

…eation.
  • Loading branch information...
Christian Achatz
Christian Achatz committed Jan 19, 2016
1 parent d7ccd54 commit 39e7c66b4519c20c2c9a39c0e30cce80327c6dc3
Showing with 14 additions and 8 deletions.
  1. +10 −4 tools/form/taglib/DateSelectorTag.php
  2. +4 −4 tools/form/taglib/TimeSelectorTag.php
@@ -202,17 +202,23 @@ public function onParseTime() {
* @version
* Version 0.1, 29.08.2009<br />
* Version 0.2, 30.12.2009 (Replaced split() with explode() because it is marked deprecated in PHP5.3.0)<br />
* Version 0.3, 19.01.2016 (ID#255: added "now" keyword for current year)<br />
*/
protected function initYearRange() {
// read the range for the year select box
if (isset($this->attributes['yearrange'])) {
if ($this->hasAttribute('yearrange')) {
$yearRange = explode('-', $this->attributes['yearrange']);
$yearRange = explode('-', $this->getAttribute('yearrange'));
if (count($yearRange) == 2) {
$this->yearRange['Start'] = trim($yearRange[0]);
$this->yearRange['End'] = trim($yearRange[1]);
// re-map special key "now" to current year
if ($this->yearRange['End'] === 'now') {
$this->yearRange['End'] = (new DateTime('now'))->format('Y');
}
}
}
}
@@ -227,9 +233,9 @@ protected function initYearRange() {
*/
protected function initOffsetNames() {
if (isset($this->attributes['offsetnames'])) {
if ($this->hasAttribute('offsetnames')) {
$offsetNames = explode(';', $this->attributes['offsetnames']);
$offsetNames = explode(';', $this->getAttribute('offsetnames'));
if (count($offsetNames) == 3) {
$this->offsetNames = [
@@ -179,9 +179,9 @@ public function onParseTime() {
protected function initHoursRange() {
// read the range for the hours select box
if (isset($this->attributes['hoursrange'])) {
if ($this->hasAttribute('hoursrange')) {
$hoursRange = explode('-', $this->attributes['hoursrange']);
$hoursRange = explode('-', $this->getAttribute('hoursrange'));
if (count($hoursRange) == 2) {
$this->hoursRange['Start'] = trim($this->appendZero($hoursRange[0]));
@@ -214,9 +214,9 @@ protected function appendZero($input) {
*/
protected function initOffsetNames() {
if (isset($this->attributes['offsetnames'])) {
if ($this->hasAttribute('offsetnames')) {
$offsetNames = explode(';', $this->attributes['offsetnames']);
$offsetNames = explode(';', $this->getAttribute('offsetnames'));
if (count($offsetNames) == 3) {
$this->offsetNames = [

0 comments on commit 39e7c66

Please sign in to comment.