summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Validator/TaskValidator.php2
-rw-r--r--doc/en_US/api-task-procedures.markdown2
-rw-r--r--tests/units/Validator/TaskValidatorTest.php47
3 files changed, 49 insertions, 2 deletions
diff --git a/app/Validator/TaskValidator.php b/app/Validator/TaskValidator.php
index 21f1abde..3fc70317 100644
--- a/app/Validator/TaskValidator.php
+++ b/app/Validator/TaskValidator.php
@@ -43,7 +43,7 @@ class TaskValidator extends BaseValidator
new Validators\MaxLength('title', t('The maximum length is %d characters', 200), 200),
new Validators\MaxLength('reference', t('The maximum length is %d characters', 50), 50),
new Validators\Date('date_due', t('Invalid date'), $this->dateParser->getParserFormats()),
- new Validators\Date('date_started', t('Invalid date'), array($this->dateParser->getUserDateTimeFormat())),
+ new Validators\Date('date_started', t('Invalid date'), $this->dateParser->getParserFormats()),
new Validators\Numeric('time_spent', t('This value must be numeric')),
new Validators\Numeric('time_estimated', t('This value must be numeric')),
);
diff --git a/doc/en_US/api-task-procedures.markdown b/doc/en_US/api-task-procedures.markdown
index 6f13e15e..cec6e0e0 100644
--- a/doc/en_US/api-task-procedures.markdown
+++ b/doc/en_US/api-task-procedures.markdown
@@ -23,7 +23,7 @@ API Task Procedures
- **recurrence_timeframe** (integer, optional)
- **recurrence_basedate** (integer, optional)
- **tags** ([]string, optional)
- - **date_started**: d/m/Y H:i format (string, optional)
+ - **date_started**: ISO8601 format (string, optional)
- Result on success: **task_id**
- Result on failure: **false**
diff --git a/tests/units/Validator/TaskValidatorTest.php b/tests/units/Validator/TaskValidatorTest.php
index fd5e41fe..12c5a497 100644
--- a/tests/units/Validator/TaskValidatorTest.php
+++ b/tests/units/Validator/TaskValidatorTest.php
@@ -80,5 +80,52 @@ class TaskValidatorTest extends Base
$result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '09/11/2017 10:50', 'date_started' => '09/11/2017 11:50'));
$this->assertFalse($result[0]);
+
+ // date_due
+ // ISO dates
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '2017-02-01'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '2017-02-01 13:15'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '2017-02-01 1:15 pm'));
+ $this->assertFalse($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '2017_02_01'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '2017_02_01 13:15'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '2017_02_01 1:15 am'));
+ $this->assertFalse($result[0]);
+
+ // d/m/Y dates
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '02/01/2017'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '02/01/2017 13:15'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_due' => '02/01/2017 1:15 pm'));
+ $this->assertFalse($result[0]);
+
+
+ // date_started
+ // ISO dates
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '2017-02-01'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '2017-02-01 13:15'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '2017-02-01 1:15 pm'));
+ $this->assertFalse($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '2017_02_01'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '2017_02_01 13:15'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '2017_02_01 1:15 pm'));
+ $this->assertFalse($result[0]);
+
+ // d/m/Y dates
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '02/01/2017'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '02/01/2017 13:15'));
+ $this->assertTrue($result[0]);
+ $result = $taskValidator->validateCreation(array('project_id' => 1, 'title' => 'test', 'date_started' => '02/01/2017 1:15 pm'));
+ $this->assertFalse($result[0]);
}
}