Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezdatetimevalidator.php
Go to the documentation of this file.
1 <?php
17 class eZDateTimeValidator extends eZInputValidator
18 {
19 static function validateDate( $day, $month, $year )
20 {
21 $check = checkdate( $month, $day, $year );
22 $datetime = mktime( 0, 0, 0, $month, $day, $year );
23 if ( !$check or
24 $datetime === false )
25 {
26 return eZInputValidator::STATE_INVALID;
27 }
28 return eZInputValidator::STATE_ACCEPTED;
29 }
30
31 static function validateTime( $hour, $minute, $second = 0 )
32 {
33 if ( preg_match( '/\d+/', trim( $hour ) ) &&
34 preg_match( '/\d+/', trim( $minute ) ) &&
35 preg_match( '/\d+/', trim( $second ) ) &&
36 $hour >= 0 && $minute >= 0 && $second >= 0 &&
37 $hour < 24 && $minute < 60 && $second < 60 )
38 {
39 return eZInputValidator::STATE_ACCEPTED;
40 }
41 return eZInputValidator::STATE_INVALID;
42 }
43
44 static function validateDateTime( $day, $month, $year, $hour, $minute, $second = 0 )
45 {
46 $check = checkdate( $month, $day, $year );
47 $datetime = mktime( $hour, $minute, $second, $month, $day, $year );
48 if ( !$check or
49 $datetime === false or
50 eZDateTimeValidator::validateTime( $hour, $minute ) == eZInputValidator::STATE_INVALID )
51 {
52 return eZInputValidator::STATE_INVALID;
53 }
54 return eZInputValidator::STATE_ACCEPTED;
55 }
56
58 }
59
60 ?>
eZDateTimeValidator
The class eZDateTimeValidator does.
Definition: ezdatetimevalidator.php:18
eZDateTimeValidator\validateTime
static validateTime( $hour, $minute, $second=0)
Definition: ezdatetimevalidator.php:31
eZDateTimeValidator\validateDate
static validateDate( $day, $month, $year)
Definition: ezdatetimevalidator.php:19
eZDateTimeValidator\validateDateTime
static validateDateTime( $day, $month, $year, $hour, $minute, $second=0)
Definition: ezdatetimevalidator.php:44
eZInputValidator
Input text validation and correction.
Definition: ezinputvalidator.php:78
eZInputValidator\STATE_ACCEPTED
const STATE_ACCEPTED
Definition: ezinputvalidator.php:79
eZInputValidator\STATE_INVALID
const STATE_INVALID
Definition: ezinputvalidator.php:81
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.