SS3.05 Defect - TimeField unable to save value of 12:00AM #1713

Closed
obj63mc opened this Issue Apr 4, 2013 · 3 comments

Comments

Projects
None yet
5 participants
Contributor

obj63mc commented Apr 4, 2013

Currently in the CMS if you setup a data object using SS_Datetime as a variable or as a variable of a page type. In the CMS when using DateTimeField you can currently not save a value of 12:00AM.

More context on this issue was originally at - http://open.silverstripe.org/ticket/8337

Steps to reproduce easily -

  1. Setup a data object like the following -
class MyObject extends DataObject { static $db = array('MyTimeValue' => 'SS_Datetime'); } 1. Setup a Model admin for your MyObject class 2. run a dev/build and then go to the CMS admin 3. In the admin create an object and set the dates time to 12:00 AM and press save. When the page reloads the time will be displayed as 12:00 PM. If you look at the database you will see if is saved as 12:00 PM. If you update the database to manually set it to 12:00 AM aka 00:00:00, when you refresh the admin page it still shows 12:00 PM.

This is currently being caused around line 101 of forms/TimeField.php where it is setting the ISO time from the database in the setValue function -

else if(Zend_Date::isDate($val, $this->getConfig('datavalueformat'))) {
$this->valueObj = new Zend_Date($val, $this->getConfig('datavalueformat'));
$this->value = $this->valueObj->get($this->getConfig('timeformat'));
}

One possible solution may be to try and have the time Set in current local first (else if statement below the above) instead of trying to convert to iso HH:mm:ss

chillu was assigned Apr 4, 2013

simonwelsh added the 3.1 label Mar 15, 2014

@chillu this issue was fixed

added assertions to verify

Owner

dhensby commented Jun 18, 2015

One thing I'd say, @gregsmirnov, is that your tests don't show that it can be saved into the DB, which is what the bug here complains about.

chillu added this to the 4.0.0 milestone May 8, 2017

Owner

chillu commented May 8, 2017

We've switched to PHP's built-in date/time intl functionality, and using the silverstripe/frameworktest module it looks like that's fixed

image

chillu closed this May 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment