Changeset 19 for types/DateTime.php
- Timestamp:
- Oct 22, 2008, 9:12:20 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
types/DateTime.php
r14 r19 1 1 <?php 2 2 3 function TypeDateTimeOnView($Item) 3 class TypeDateTime 4 4 { 5 global $MonthNames; 5 function OnView($Item) 6 { 7 global $MonthNames; 6 8 7 $ValueParts = explode(' ', $Item['Value']);8 $DateParts = explode('-', $ValueParts[0]);9 $TimeParts = explode(':', $ValueParts[1]);9 $ValueParts = explode(' ', $Item['Value']); 10 $DateParts = explode('-', $ValueParts[0]); 11 $TimeParts = explode(':', $ValueParts[1]); 10 12 11 $Output = $TimeParts[0].':'.$TimeParts[1].':'.$TimeParts[2].' '.($DateParts[2] * 1).'. '.$MonthNames[$DateParts[1] * 1].' '.$DateParts[0]; 12 return($Output); 13 $Output = $TimeParts[0].':'.$TimeParts[1].':'.$TimeParts[2].' '.($DateParts[2] * 1).'. '.$MonthNames[$DateParts[1] * 1].' '.$DateParts[0]; 14 return($Output); 15 } 16 17 function OnEdit($Item) 18 { 19 global $MonthNames; 20 21 $ValueParts = explode(' ', $Item['Value']); 22 $DateParts = explode('-', $ValueParts[0]); 23 $TimeParts = explode(':', $ValueParts[1]); 24 25 // Hour 26 $Output = '<select name="'.$Item['Name'].'-hour">'; 27 for($I = 1; $I <= 24; $I++) 28 { 29 if($TimeParts[2] == $I) $Selected = ' selected="1"'; else $Selected = ''; 30 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 31 } 32 $Output .= '</select>'; 33 // Minute 34 $Output .= '<select name="'.$Item['Name'].'-minute">'; 35 for($I = 1; $I <= 60; $I++) 36 { 37 if($TimeParts[1] == $I) $Selected = ' selected="1"'; else $Selected = ''; 38 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 39 } 40 $Output .= '</select>'; 41 // Second 42 $Output .= '<select name="'.$Item['Name'].'-second">'; 43 for($I = 1; $I <= 60; $I++) 44 { 45 if($TimeParts[0] == $I) $Selected = ' selected="1"'; else $Selected = ''; 46 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 47 } 48 $Output .= '</select>'; 49 // Day 50 $Output .= ' <select name="'.$Item['Name'].'-day">'; 51 for($I = 1; $I <= 31; $I++) 52 { 53 if($DateParts[2] == $I) $Selected = ' selected="1"'; else $Selected = ''; 54 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 55 } 56 $Output .= '</select>'; 57 // Month 58 $Output .= '<select name="'.$Item['Name'].'-month">'; 59 for($I = 1; $I <= 12; $I++) 60 { 61 if($DateParts[1] == $I) $Selected = ' selected="1"'; else $Selected = ''; 62 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>'; 63 } 64 $Output .= '</select>'; 65 // Year 66 $Output .= '<select name="'.$Item['Name'].'-year">'; 67 for($I = 1900; $I < 2100; $I++) 68 { 69 if($DateParts[0] == $I) $Selected = ' selected="1"'; else $Selected = ''; 70 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 71 } 72 $Output .= '</select>'; 73 return($Output); 74 } 75 76 function OnLoad($Item) 77 { 78 return($_POST[$Item['Name'].'-year'].'-'.$_POST[$Item['Name'].'-month'].'-'.$_POST[$Item['Name'].'-day'].' '. 79 $_POST[$Item['Name'].'-hour'].':'.$_POST[$Item['Name'].'-minute'].':'.$_POST[$Item['Name'].'-second']); 80 } 13 81 } 14 82 15 function TypeDateTimeOnEdit($Item) 16 { 17 global $MonthNames; 18 19 $ValueParts = explode(' ', $Item['Value']); 20 $DateParts = explode('-', $ValueParts[0]); 21 $TimeParts = explode(':', $ValueParts[1]); 22 23 // Hour 24 $Output = '<select name="'.$Item['Name'].'-hour">'; 25 for($I = 1; $I <= 24; $I++) 26 { 27 if($TimeParts[2] == $I) $Selected = ' selected="1"'; else $Selected = ''; 28 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 29 } 30 $Output .= '</select>'; 31 // Minute 32 $Output .= '<select name="'.$Item['Name'].'-minute">'; 33 for($I = 1; $I <= 60; $I++) 34 { 35 if($TimeParts[1] == $I) $Selected = ' selected="1"'; else $Selected = ''; 36 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 37 } 38 $Output .= '</select>'; 39 // Second 40 $Output .= '<select name="'.$Item['Name'].'-second">'; 41 for($I = 1; $I <= 60; $I++) 42 { 43 if($TimeParts[0] == $I) $Selected = ' selected="1"'; else $Selected = ''; 44 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 45 } 46 $Output .= '</select>'; 47 // Day 48 $Output .= ' <select name="'.$Item['Name'].'-day">'; 49 for($I = 1; $I <= 31; $I++) 50 { 51 if($DateParts[2] == $I) $Selected = ' selected="1"'; else $Selected = ''; 52 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 53 } 54 $Output .= '</select>'; 55 // Month 56 $Output .= '<select name="'.$Item['Name'].'-month">'; 57 for($I = 1; $I <= 12; $I++) 58 { 59 if($DateParts[1] == $I) $Selected = ' selected="1"'; else $Selected = ''; 60 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>'; 61 } 62 $Output .= '</select>'; 63 // Year 64 $Output .= '<select name="'.$Item['Name'].'-year">'; 65 for($I = 1900; $I < 2100; $I++) 66 { 67 if($DateParts[0] == $I) $Selected = ' selected="1"'; else $Selected = ''; 68 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 69 } 70 $Output .= '</select>'; 71 return($Output); 72 } 73 74 function TypeDateTimeOnLoad($Item) 75 { 76 return($_POST[$Item['Name'].'-year'].'-'.$_POST[$Item['Name'].'-month'].'-'.$_POST[$Item['Name'].'-day'].' '. 77 $_POST[$Item['Name'].'-hour'].':'.$_POST[$Item['Name'].'-minute'].':'.$_POST[$Item['Name'].'-second']); 78 } 83 $TypeDefinitionList['DateTime'] = new TypeDateTime; 79 84 80 85 ?>
Note:
See TracChangeset
for help on using the changeset viewer.