Skip to content
This repository
Browse code

Fixed #830

  • Loading branch information...
commit ed032ac6996a5d320ac88540252c06be0fa28439 1 parent f5551d8
Vladimir Sibirov authored February 18, 2012

Showing 1 changed file with 37 additions and 0 deletions. Show diff stats Hide diff stats

  1. 37  system/functions.php
37  system/functions.php
@@ -3076,6 +3076,43 @@ function cot_mktime($hour = false, $minute = false, $second = false, $month = fa
3076 3076
 	return mktime ((int) $hour, (int) $minute, (int) $second, (int) $month, (int) $date, (int) $year);
3077 3077
 }
3078 3078
 
  3079
+if (!function_exists('strptime'))
  3080
+{
  3081
+	/**
  3082
+	 * strptime() for Windows
  3083
+	 * @author ex/yks toolkit
  3084
+	 * @license MIT
  3085
+	 * @param string $date
  3086
+	 * @param string $format
  3087
+	 * @return boolean 
  3088
+	 */
  3089
+	function strptime($date, $format)
  3090
+	{
  3091
+		$masks = array(
  3092
+			'%d' => '(?P<d>[0-9]{2})',
  3093
+			'%m' => '(?P<m>[0-9]{2})',
  3094
+			'%Y' => '(?P<Y>[0-9]{4})',
  3095
+			'%H' => '(?P<H>[0-9]{2})',
  3096
+			'%M' => '(?P<M>[0-9]{2})',
  3097
+			'%S' => '(?P<S>[0-9]{2})'
  3098
+		);
  3099
+
  3100
+		$rexep = "#" . strtr(preg_quote($format), $masks) . "#";
  3101
+		if (!preg_match($rexep, $date, $out))
  3102
+			return false;
  3103
+
  3104
+		$ret = array(
  3105
+			"tm_sec" => (int) $out['S'],
  3106
+			"tm_min" => (int) $out['M'],
  3107
+			"tm_hour" => (int) $out['H'],
  3108
+			"tm_mday" => (int) $out['d'],
  3109
+			"tm_mon" => $out['m'] ? $out['m'] - 1 : 0,
  3110
+			"tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0,
  3111
+		);
  3112
+		return $ret;
  3113
+	}
  3114
+}
  3115
+
3079 3116
 /**
3080 3117
  * Converts date into UNIX timestamp.
3081 3118
  * Like strptime() but using formatting as specified for date().

0 notes on commit ed032ac

Please sign in to comment.
Something went wrong with that request. Please try again.