X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=format.php;h=f90fc1f15c4ba9f876dc851e32e56206d9705a4c;hb=5061f0bf1235972ff1a6d8f3e01097ae84b0107e;hp=8035be44641afb928d3c6c88bfd7d32491c342e5;hpb=456602c35b5550a0ab8cbaf4c74ca6d00a3be076;p=wfpl.git diff --git a/format.php b/format.php index 8035be4..f90fc1f 100644 --- a/format.php +++ b/format.php @@ -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);