Store due date without the time
This commit is contained in:
@@ -87,13 +87,13 @@ class DateParser extends Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For a given timestamp, reset the date to midnight
|
* Remove the time from a timestamp
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param integer $timestamp Timestamp
|
* @param integer $timestamp Timestamp
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function resetDateToMidnight($timestamp)
|
public function removeTimeFromTimestamp($timestamp)
|
||||||
{
|
{
|
||||||
return mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp));
|
return mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp));
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ class DateParser extends Base
|
|||||||
*/
|
*/
|
||||||
public function getTimestampFromIsoFormat($date)
|
public function getTimestampFromIsoFormat($date)
|
||||||
{
|
{
|
||||||
return $this->resetDateToMidnight(strtotime($date));
|
return $this->removeTimeFromTimestamp(strtotime($date));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,7 +147,7 @@ class DateParser extends Base
|
|||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
|
|
||||||
if (! empty($values[$field]) && ! is_numeric($values[$field])) {
|
if (! empty($values[$field]) && ! is_numeric($values[$field])) {
|
||||||
$values[$field] = $this->getTimestamp($values[$field]);
|
$values[$field] = $this->removeTimeFromTimestamp($this->getTimestamp($values[$field]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,11 +94,11 @@ class SubtaskExport extends Base
|
|||||||
public function getSubtasks($project_id, $from, $to)
|
public function getSubtasks($project_id, $from, $to)
|
||||||
{
|
{
|
||||||
if (! is_numeric($from)) {
|
if (! is_numeric($from)) {
|
||||||
$from = $this->dateParser->resetDateToMidnight($this->dateParser->getTimestamp($from));
|
$from = $this->dateParser->removeTimeFromTimestamp($this->dateParser->getTimestamp($from));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! is_numeric($to)) {
|
if (! is_numeric($to)) {
|
||||||
$to = $this->dateParser->resetDateToMidnight(strtotime('+1 day', $this->dateParser->getTimestamp($to)));
|
$to = $this->dateParser->removeTimeFromTimestamp(strtotime('+1 day', $this->dateParser->getTimestamp($to)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->db->table(SubTask::TABLE)
|
return $this->db->table(SubTask::TABLE)
|
||||||
|
|||||||
@@ -77,11 +77,11 @@ class TaskExport extends Base
|
|||||||
';
|
';
|
||||||
|
|
||||||
if (! is_numeric($from)) {
|
if (! is_numeric($from)) {
|
||||||
$from = $this->dateParser->resetDateToMidnight($this->dateParser->getTimestamp($from));
|
$from = $this->dateParser->removeTimeFromTimestamp($this->dateParser->getTimestamp($from));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! is_numeric($to)) {
|
if (! is_numeric($to)) {
|
||||||
$to = $this->dateParser->resetDateToMidnight(strtotime('+1 day', $this->dateParser->getTimestamp($to)));
|
$to = $this->dateParser->removeTimeFromTimestamp(strtotime('+1 day', $this->dateParser->getTimestamp($to)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$rq = $this->db->execute($sql, array($from, $to, $project_id));
|
$rq = $this->db->execute($sql, array($from, $to, $project_id));
|
||||||
|
|||||||
@@ -29,4 +29,22 @@ class DateParserTest extends Base
|
|||||||
$this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('2014_03_05')));
|
$this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('2014_03_05')));
|
||||||
$this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('03/05/2014')));
|
$this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('03/05/2014')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testConvert()
|
||||||
|
{
|
||||||
|
$d = new DateParser($this->container);
|
||||||
|
|
||||||
|
$values = array(
|
||||||
|
'date_due' => '2015-01-25',
|
||||||
|
'date_started' => '2015_01_25',
|
||||||
|
);
|
||||||
|
|
||||||
|
$d->convert($values, array('date_due', 'date_started'));
|
||||||
|
|
||||||
|
$this->assertEquals(mktime(0, 0, 0, 1, 25, 2015), $values['date_due']);
|
||||||
|
$this->assertEquals('2015-01-25', date('Y-m-d', $values['date_due']));
|
||||||
|
|
||||||
|
$this->assertEquals(mktime(0, 0, 0, 1, 25, 2015), $values['date_started']);
|
||||||
|
$this->assertEquals('2015-01-25', date('Y-m-d', $values['date_started']));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user