Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00032 class ilMDUtils
00033 {
00042 function _LOMDurationToArray($a_string)
00043 {
00044 $a_string = trim($a_string);
00045 #$pattern = '/^(PT)?(\d{1,2}H)?(\d{1,2}M)?(\d{1,2}S)?$/i';
00046 $pattern = '/^P(\d{1,2}M)?(\d{1,2}D)?(T(\d{1,2}H)?(\d{1,2}M)?(\d{1,2}S)?)?$/i';
00047
00048 if(!preg_match($pattern,$a_string,$matches))
00049 {
00050 return false;
00051 }
00052
00053 if(preg_match('/^P(\d+)M/i',$a_string,$matches))
00054 {
00055 $months = $matches[1];
00056 }
00057
00058 if(preg_match('/(\d+)+D/i',$a_string,$matches))
00059 {
00060 #var_dump("<pre>",$matches,"<pre>");
00061 $days = $matches[1];
00062 }
00063
00064 if(preg_match('/(\d+)+H/i',$a_string,$matches))
00065 {
00066 #var_dump("<pre>",$matches,"<pre>");
00067 $hours = $matches[1];
00068 }
00069 if(preg_match('/T(\d{1,2}H)?(\d+)M/i',$a_string,$matches))
00070 {
00071 #var_dump("<pre>",$matches,"<pre>");
00072 $min = $matches[2];
00073 }
00074 if(preg_match('/(\d+)S/i',$a_string,$matches))
00075 {
00076 #var_dump("<pre>",$matches,"<pre>");
00077 $sec = $matches[1];
00078 }
00079
00080
00081 if(!$months and !$days and !$hours and !$min and !$sec)
00082 {
00083 return false;
00084 }
00085
00086 return array($months,$days,$hours,$min,$sec);
00087 }
00088
00089
00090 }