parent
e0584540e3
commit
fa112d7888
@ -1,40 +1,23 @@ |
|||||||
<?php |
<?php |
||||||
// $Id: Date.php 6187 2005-09-07 10:23:57Z bmol $ |
/* For licensing terms, see /license.txt */ |
||||||
/* |
/** @author Bart Mollet, Julio Montoya */ |
||||||
============================================================================== |
require_once 'HTML/QuickForm/Rule.php'; |
||||||
Dokeos - elearning and course management software |
|
||||||
|
|
||||||
Copyright (c) 2004-2005 Dokeos S.A. |
|
||||||
Copyright (c) Bart Mollet, Hogeschool Gent |
|
||||||
|
|
||||||
For a full list of contributors, see "credits.txt". |
|
||||||
The full license can be read in "license.txt". |
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or |
|
||||||
modify it under the terms of the GNU General Public License |
|
||||||
as published by the Free Software Foundation; either version 2 |
|
||||||
of the License, or (at your option) any later version. |
|
||||||
|
|
||||||
See the GNU General Public License for more details. |
|
||||||
|
|
||||||
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium |
|
||||||
Mail: info@dokeos.com |
|
||||||
============================================================================== |
|
||||||
*/ |
|
||||||
require_once ('HTML/QuickForm/Rule.php'); |
|
||||||
/** |
/** |
||||||
* QuickForm rule to check a date |
* Class HTML_QuickForm_Rule_Date |
||||||
*/ |
*/ |
||||||
class HTML_QuickForm_Rule_Date extends HTML_QuickForm_Rule |
class HTML_QuickForm_Rule_Date extends HTML_QuickForm_Rule |
||||||
{ |
{ |
||||||
/** |
/** |
||||||
* Function to check a date |
* Check a date |
||||||
* @see HTML_QuickForm_Rule |
* @see HTML_QuickForm_Rule |
||||||
* @param array $date An array with keys F (month), d (day) and Y (year) |
* @param string $date example 2014-04-30 |
||||||
|
* @param array $options |
||||||
|
* |
||||||
* @return boolean True if date is valid |
* @return boolean True if date is valid |
||||||
*/ |
*/ |
||||||
function validate($date, $options) |
public function validate($date, $options) |
||||||
{ |
{ |
||||||
return checkdate($date['F'], $date['d'], $date['Y']); |
return api_is_valid_date($date, 'Y-m-d'); |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,46 +1,21 @@ |
|||||||
<?php |
<?php |
||||||
// $Id: DateCompare.php 6187 2005-09-07 10:23:57Z bmol $ |
/* For licensing terms, see /license.txt */ |
||||||
/* |
/** @author Bart Mollet, Julio Montoya */ |
||||||
============================================================================== |
|
||||||
Dokeos - elearning and course management software |
|
||||||
|
|
||||||
Copyright (c) 2004-2005 Dokeos S.A. |
|
||||||
Copyright (c) Bart Mollet, Hogeschool Gent |
|
||||||
|
|
||||||
For a full list of contributors, see "credits.txt". |
|
||||||
The full license can be read in "license.txt". |
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or |
|
||||||
modify it under the terms of the GNU General Public License |
|
||||||
as published by the Free Software Foundation; either version 2 |
|
||||||
of the License, or (at your option) any later version. |
|
||||||
|
|
||||||
See the GNU General Public License for more details. |
|
||||||
|
|
||||||
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium |
|
||||||
Mail: info@dokeos.com |
|
||||||
============================================================================== |
|
||||||
*/ |
|
||||||
require_once 'HTML/QuickForm/Rule/Compare.php'; |
require_once 'HTML/QuickForm/Rule/Compare.php'; |
||||||
/** |
/** |
||||||
* QuickForm rule to compare 2 dates |
* Class HTML_QuickForm_Rule_DateCompare |
||||||
*/ |
*/ |
||||||
class HTML_QuickForm_Rule_DateCompare extends HTML_QuickForm_Rule_Compare |
class HTML_QuickForm_Rule_DateCompare extends HTML_QuickForm_Rule_Compare |
||||||
{ |
{ |
||||||
/** |
/** |
||||||
* Validate 2 dates |
* Validate 2 dates |
||||||
* @param array $values Array with the 2 dates. Each element in this array |
* @param array $values Array with the 2 dates. |
||||||
* should be an array width keys F (month), d (day) and Y (year) |
* @param $operator |
||||||
* @param string $operator The operator to use (default '==') |
* |
||||||
* @return boolean True if the 2 given dates match the operator |
* @return boolean true if the 2 given dates match the operator |
||||||
*/ |
*/ |
||||||
function validate($values, $operator = null) |
function validate($values, $operator = null) |
||||||
{ |
{ |
||||||
$date1 = $values[0]; |
return api_strtotime($values[0]) < api_strtotime($values[1]); |
||||||
$date2 = $values[1]; |
|
||||||
$time1 = mktime($date1['H'],$date1['i'],0,$date1['F'],$date1['d'],$date1['Y']); |
|
||||||
$time2 = mktime($date2['H'],$date2['i'],0,$date2['F'],$date2['d'],$date2['Y']); |
|
||||||
return parent::validate(array($time1,$time2),$operator); |
|
||||||
} |
} |
||||||
} |
} |
||||||
?> |
|
Loading…
Reference in new issue