Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Form / Element / Month.php
blob70a39b046dc6dbcc53bd61ca614b75803da25cae
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Form\Element;
12 use Zend\Form\Element;
13 use Zend\Validator\DateStep as DateStepValidator;
14 use Zend\Validator\Regex as RegexValidator;
15 use Zend\Validator\ValidatorInterface;
17 class Month extends DateTime
19 /**
20 * Seed attributes
22 * @var array
24 protected $attributes = array(
25 'type' => 'month',
28 /**
29 * Retrieves a Date Validator configured for a Month Input type
31 * @return ValidatorInterface
33 protected function getDateValidator()
35 return new RegexValidator('/^[0-9]{4}\-(0[1-9]|1[012])$/');
38 /**
39 * Retrieves a DateStep Validator configured for a Month Input type
41 * @return ValidatorInterface
43 protected function getStepValidator()
45 $stepValue = (isset($this->attributes['step']))
46 ? $this->attributes['step'] : 1; // Months
48 $baseValue = (isset($this->attributes['min']))
49 ? $this->attributes['min'] : '1970-01';
51 return new DateStepValidator(array(
52 'format' => "Y-m",
53 'baseValue' => $baseValue,
54 'step' => new \DateInterval("P{$stepValue}M"),
55 ));