Skip to content

Commit

Permalink
Fixed #830
Browse files Browse the repository at this point in the history
  • Loading branch information
trustmaster committed Feb 18, 2012
1 parent f5551d8 commit ed032ac
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions system/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3076,6 +3076,43 @@ function cot_mktime($hour = false, $minute = false, $second = false, $month = fa
return mktime ((int) $hour, (int) $minute, (int) $second, (int) $month, (int) $date, (int) $year);
}

if (!function_exists('strptime'))
{
/**
* strptime() for Windows
* @author ex/yks toolkit
* @license MIT
* @param string $date
* @param string $format
* @return boolean
*/
function strptime($date, $format)
{
$masks = array(
'%d' => '(?P<d>[0-9]{2})',
'%m' => '(?P<m>[0-9]{2})',
'%Y' => '(?P<Y>[0-9]{4})',
'%H' => '(?P<H>[0-9]{2})',
'%M' => '(?P<M>[0-9]{2})',
'%S' => '(?P<S>[0-9]{2})'
);

$rexep = "#" . strtr(preg_quote($format), $masks) . "#";
if (!preg_match($rexep, $date, $out))
return false;

$ret = array(
"tm_sec" => (int) $out['S'],
"tm_min" => (int) $out['M'],
"tm_hour" => (int) $out['H'],
"tm_mday" => (int) $out['d'],
"tm_mon" => $out['m'] ? $out['m'] - 1 : 0,
"tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0,
);
return $ret;
}
}

/**
* Converts date into UNIX timestamp.
* Like strptime() but using formatting as specified for date().
Expand Down

0 comments on commit ed032ac

Please sign in to comment.