/** Split date, time or timeStamp, answer array with keys from format
* Limitation: only works for formats using Y, m, d, H, i and/or s
* and separators from getTimeStampSeparators()
* @static
* @param String date, time or timestamp String
* @param String $format
* @return Array of String
*/
static function ($value, $format) {
$expr = '/['.str_replace('/', '\/', StringConverter::getTimeStampSeparators()).']/';
$formatArray = preg_split($expr, $format);
if (count($formatArray) == 1) {
$formatArray = array();
for ($i=0; $i<strLen($format); $i++)
$formatArray[] = subStr($format, $i, 1);
$arr = StringConverter::splitDtNoSeparators($value, $formatArray);
} else {
$arr = preg_split($expr, $value);
}
for ($i=0; $i<count($formatArray); $i++)
$result[$formatArray[$i]] = isSet($arr[$i]) ? $arr[$i] : '00';
if (isSet($result['d']))
$result['j'] = (int) $result['d'];
if (isSet($result['m']))
$result['n'] = (int) $result['m'];
return $result;
}
|