Update passport validation and date parse routine for data import
This commit is contained in:
@@ -62,7 +62,7 @@ function _valid_passport_number($input) {
|
||||
//strip whitespace
|
||||
$passport = preg_replace( '/\s+/', '', $input );
|
||||
//check for a match
|
||||
if (preg_match('/^[a-zA-Z]\d{7}$/', $input, $matches)) {
|
||||
if (preg_match('/^[a-zA-Z]{1,2}\d{7}$/', $input, $matches)) {
|
||||
watchdog('booking', 'Passport number "!passnum" validates since it passed our regexp',
|
||||
array('!passnum' => $input));
|
||||
return TRUE;
|
||||
@@ -243,9 +243,9 @@ function _datetime_to_ts($date) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to turn a loosely formatted date into a timestamp
|
||||
* Function to turn a loosely formatted date into a timestamp, with optional time
|
||||
*
|
||||
* @param $date in format DD/MM/YYYY HH:mm
|
||||
* @param $date in format DD/MM/YYYY HH:mm or just DD/MM/YYYY
|
||||
* @return unix timestamp formatted for current time zone
|
||||
*/
|
||||
function _datetime_to_ts_nonstrict($date) {
|
||||
@@ -254,7 +254,13 @@ function _datetime_to_ts_nonstrict($date) {
|
||||
//check for a match
|
||||
if (preg_match($pattern, $date, $matches))
|
||||
{
|
||||
$date_split = $matches;
|
||||
//$date_split = $matches;
|
||||
$hour = isset($matches[5]) ? $matches[5] : 0;
|
||||
$minute = isset($matches[6]) ? $matches[6] : 0;
|
||||
$second = 0;
|
||||
$month = $matches[2];
|
||||
$day = $matches[1];
|
||||
$year = $matches[3];
|
||||
}
|
||||
//return zero now if no matches
|
||||
else
|
||||
@@ -265,12 +271,12 @@ function _datetime_to_ts_nonstrict($date) {
|
||||
date_default_timezone_set(TIMEZONE);
|
||||
$tz = new DateTimeZone(TIMEZONE);
|
||||
|
||||
$gmt_ts = mktime($date_split[5], $date_split[6], 0, $date_split[2], $date_split[1], $date_split[3]);
|
||||
//$gmt_ts = mktime($date_split[5], $date_split[6], 0, $date_split[2], $date_split[1], $date_split[3]);
|
||||
$gmt_ts = mktime($hour, $minute, $second, $month, $day, $year);
|
||||
$ts = new DateTime("@$gmt_ts");
|
||||
$ts->setTimezone($tz);
|
||||
|
||||
return $ts->format("U");
|
||||
|
||||
return $ts->format("U");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user