Ticket #886 (closed defect: fixed)

Opened 4 months ago

Last modified 4 months ago

TSimpleDateFormatter: One month offset in time stamp with date pattern "yyyy"

Reported by: knut Owned by: knut
Priority: normal Milestone: 3.1.3
Component: Prado Framework v3 Version: 3.1
Severity: minor Keywords:
Cc:

Description

The parse()-method of TSimpleDateFormatter returns wrong timestamp if pattern is only set to year (yyyy).

Steps to reproduce:

<?php
require_once 'path/to/framework/prado.php';
require_once 'path/to/framework/Util/TSimpleDateFormatter.php';
$formatter = new TSimpleDateFormatter("yyyy");
echo date('Y-m-d', $formatter->parse("2008"))."\n";
?>

Actual output: 2007-12-01 Expected output: 2008-01-01

The bug affects every web control that make use of the TSimpleDateFormatter (like TDatePicker) where you want the TimeStamp? property.

Here's another example using TDatePicker experiencing the same problem:

TDatePickerYearTest.page:

<com:TContent id="Main">
  <com:TDatePicker ID="Year" DateFormat="yyyy" InputMode="DropDownList"/>
  <com:TButton ButtonType="Submit" Text="Send" onClick="onButtonClicked" />
</com:TContent>

TDatePickerYearTest.php:

<?php
class TDatePickerYearTest extends TPage {
  public function onButtonClicked($sender, $param) {
    echo "<p>Date: ".Prado::varDump($this->Year->Date)."</p>";
    echo "<p>TimeStamp: ".Prado::varDump(date('Y-m-d', $this->Year->TimeStamp))."</p>";
    echo "<p>Text: ".Prado::varDump($this->Year->Text)."</p>";
    exit(0);
  }
}
?>

Change History

Changed 4 months ago by knut

  • owner changed from xue to knut

Changed 4 months ago by knut

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.