Browse files

MINOR Removed unnecessary $timeformat parameter from TimeField::__con…

…struct, and getting the default from Zend_Locale_Format in the same way that DateField behaves (unreleased API, so no api change).

MINOR Automatically choosing $locale in TimeField::__construct, to be consistent with DateField

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@103975 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 641b936 commit eb11951aceee0546ad387adea0b66d603c08b4a2 @chillu chillu committed with sminnee May 3, 2010
Showing with 8 additions and 15 deletions.
  1. +8 −15 forms/TimeField.php
View
23 forms/TimeField.php
@@ -30,7 +30,7 @@ class TimeField extends TextField {
protected $config = array(
'showdropdown' => false,
- 'timeformat' => null,
+ 'timeformat' => 'HH:mm:ss',
'use_strtotime' => true,
'datavalueformat' => 'HH:mm:ss'
);
@@ -47,20 +47,13 @@ class TimeField extends TextField {
*/
protected $valueObj = null;
- /**
- * Constructor saves the format difference. Timefields shouldn't
- * have a problem with length as times can only be represented in on way.
- *
- * @param $name string The name of the field
- * @param $title string The Title of the field
- * @param $value string the value for the field
- * @param $timeformat string The Time format in ISO format (see Zend_Date)
- */
- function __construct($name, $title = null, $value = "",$timeformat = 'HH:mm:ss'){
- if($timeformat) {
- $this->setConfig('timeformat', $timeformat);
- } else {
- $this->setConfig('timeformat', Zend_Locale_Format::getTimeFormat($this->locale));
+ function __construct($name, $title = null, $value = ""){
+ if(!$this->locale) {
+ $this->locale = i18n::get_locale();
+ }
+
+ if(!$this->getConfig('timeformat')) {
+ $this->setConfig('timeformat', Zend_Locale_Format::getDateFormat($this->locale));
}
parent::__construct($name,$title,$value);

0 comments on commit eb11951

Please sign in to comment.