"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
- "hash": "e5ea80198a9aa0bc5288cbdbe34949e7",
+ "hash": "57c4d731e20fcf4857e1a79b7884e303",
"packages": [
{
"name": "andy128k/ipf-template",
},
"time": "2013-07-30 22:57:26"
},
+ {
+ "name": "andy128k/missing-tools",
+ "version": "dev-master",
+ "source": {
+ "type": "git",
+ "url": "git://git.andy128k.net/missing-tools.git",
+ "reference": "2eadebd11488194e45d75b722bc0ebbabf15dcc3"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "3.7.*"
+ },
+ "type": "library",
+ "autoload": {
+ "classmap": [
+ "src"
+ ]
+ },
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Andrey Kutejko",
+ "email": "andy128k@gmail.com"
+ }
+ ],
+ "description": "Miscellaneous utilities",
+ "time": "2013-08-10 18:31:29"
+ },
{
"name": "andy128k/routeexpression",
"version": "dev-master",
},
{
"name": "phpunit/php-token-stream",
- "version": "1.1.8",
+ "version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
- "reference": "1.1.8"
+ "reference": "1.2.0"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1.1.8",
- "reference": "1.1.8",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1.2.0",
+ "reference": "1.2.0",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.2-dev"
+ }
+ },
"autoload": {
"classmap": [
"PHP/"
"keywords": [
"tokenizer"
],
- "time": "2013-08-02 19:10:55"
+ "time": "2013-08-04 05:57:48"
},
{
"name": "phpunit/phpunit",
- "version": "3.7.23",
+ "version": "3.7.24",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "3.7.23"
+ "reference": "3.7.24"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.23",
- "reference": "3.7.23",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.24",
+ "reference": "3.7.24",
"shasum": ""
},
"require": {
"testing",
"xunit"
],
- "time": "2013-08-02 19:14:44"
+ "time": "2013-08-09 06:58:24"
},
{
"name": "phpunit/phpunit-mock-objects",
},
{
"name": "symfony/yaml",
- "version": "v2.3.2",
+ "version": "v2.3.3",
"target-dir": "Symfony/Component/Yaml",
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
- "reference": "v2.3.2"
+ "reference": "v2.3.3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.3.2",
- "reference": "v2.3.2",
+ "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.3.3",
+ "reference": "v2.3.3",
"shasum": ""
},
"require": {
],
"description": "Symfony Yaml Component",
"homepage": "http://symfony.com",
- "time": "2013-07-11 19:36:36"
+ "time": "2013-07-21 12:12:18"
}
],
"aliases": [
],
"minimum-stability": "stable",
"stability-flags": {
+ "andy128k/missing-tools": 20,
"andy128k/routeexpression": 20,
"andy128k/ipf-template": 20
},
class IPF_Form_Widget_DateInput extends IPF_Form_Widget_Input
{
public $input_type = 'text';
- public $format = 'Y-m-d';
+ public $format = IPF_Format::DATE_ISO8601;
+
+ public function __construct($attrs=array())
+ {
+ $format = ArrayTools::pop($attrs, 'format');
+ if ($format)
+ $this->format = is_string($format) ? IPF_Format::flagsFromString($format) : $format;
+
+ parent::__construct($attrs);
+ }
public function render($name, $value, $extra_attrs=array())
{
- if (strlen($value) > 0) {
- $value = date($this->format, strtotime($value));
- }
$extra_attrs['class'] = 'dateinput';
+ $extra_attrs['data-format'] = IPF_Format::makeFormat($this->format, array('yy', 'mm', 'dd'));
return parent::render($name, $value, $extra_attrs);
}
-}
\ No newline at end of file
+
+ public function valueFromFormData($name, &$data)
+ {
+ if (!isset($data[$name]) || !$data[$name]) {
+ return null;
+ }
+
+ $date = IPF_Format::parseDate($this->format, $data[$name]);
+ if ($date !== false) {
+ $day = str_pad($date['tm_mday'], 2, '0', STR_PAD_LEFT);
+ $month = str_pad($date['tm_mon']+1, 2, '0', STR_PAD_LEFT);
+ $year = str_pad($date['tm_year']+1900, 4, '0', STR_PAD_LEFT);
+ return $year.'-'.$month.'-'.$day;
+ } else {
+ return null;
+ }
+ }
+
+ public function valueToFormData($name, $data)
+ {
+ if (isset($data[$name]) && $data[$name]) {
+ return IPF_Format::formatDate($this->format, strtotime($data[$name]));
+ } else {
+ return null;
+ }
+ }
+}
+