return substr($yyyy_mm_dd, 5, 2) . '/' . substr($yyyy_mm_dd, 8, 2) . '/' . substr($yyyy_mm_dd, 0, 4);
}
+# depricated. call enc_mmddyyyy() instead
+function enc_mdy($str) {
+ return enc_mmddyyyy($str);
+}
+
function enc_mmddyyyyhhmm($seconds) {
return date('m/d/Y g:ia', (int)$seconds);
}
return $str;
}
+# takes decimal
+# returns hh:mm followed by "am" or "pm" with no space
+function enc_12hr($str) {
+ if(strlen($str) == 0) {
+ return '';
+ }
+ $hours = floor($str);
+ $minutes = round(($str - $hours) * 60);
+ $suffix = 'am';
+ if($hours >= 12.0) {
+ $suffix = 'pm';
+ if($hours > 12.0) {
+ $hours -= 12.0;
+ }
+ }
+ $str = sprintf("%d:%02d", $hours, $minutes);
+ $str .= $suffix;
+ return $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
#
}
}
+# 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);
# This file contains functions to manipulate/calculate dates/times
+# FIXME make it so you can call this with a string YYYY-MM-DD
function ymd_to_days($year, $month, $day) {
return (int)(mktime(12,0,0,$month,$day, $year, 0) / 86400);
}
list($year, $month, $day) = ymd_clean($str);
return sprintf('%02u/%02u/%04u', $month, $day, $year);
}
-
-function enc_mdy($str) {
- return ymd_to_mdy($str);
-}
-
-function format_ymd($str) {
- list($year, $month, $day) = ymd_clean($str);
- return sprintf('%04u-%02u-%02u', $year, $month, $day);
-}