JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
added code for 12 hour time formatting. Moved enc_mdy and format_ymd out of time.php
[wfpl.git] / format.php
index 8035be4..f90fc1f 100644 (file)
@@ -218,6 +218,13 @@ function format_mdy_to_ymd($str) {
        return mdy_to_ymd(format_oneline($str));
 }
 
+# date is yyyy-mm-dd
+function format_ymd($str) {
+       require_once('code/wfpl/time.php');
+       list($year, $month, $day) = ymd_clean($str);
+       return sprintf('%04u-%02u-%02u', $year, $month, $day);
+}
+
 # takes any of: HH  :MM  HH:MM
 # returns decimal number of hours
 #
@@ -253,6 +260,19 @@ function format_hours($str) {
        }
 }
 
+# takes eg 12:23am
+# returns decimal number of hours since midnight
+function format_12hr_to_hours($str) {
+       if(eregi('noon', $str)) {
+               return 12;
+       }
+       $hours = format_hours($str);
+       if($hours < 12 && eregi('p', $str)) {
+               $hours += 12;
+       }
+       return $hours;
+}
+
 
 function format_phone($str) {
        $str = ereg_replace('[^0-9]', '', $str);