JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
updated docs
[wfpl.git] / time.php
index 81f4048..4c6b1f1 100644 (file)
--- a/time.php
+++ b/time.php
@@ -2,21 +2,18 @@
 
 #  Copyright (C) 2007 Jason Woofenden
 #
-#  This file is part of wfpl.
-#
-#  wfpl is free software; you can redistribute it and/or modify it under the
-#  terms of the GNU Lesser General Public License as published by the Free
-#  Software Foundation; either version 2.1 of the License, or (at your option)
-#  any later version.
-#
-#  wfpl is distributed in the hope that it will be useful, but WITHOUT ANY
-#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-#  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
-#  more details.
-#
-#  You should have received a copy of the GNU Lesser General Public License
-#  along with wfpl; if not, write to the Free Software Foundation, Inc., 51
-#  Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+#  This program is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#  
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#  
+#  You should have received a copy of the GNU General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 # This file contains functions to manipulate/calculate dates/times
@@ -73,7 +70,7 @@ function clean_ymd($year, $month, $day) {
        return array($year, $month, $day);
 }
 
-# convert date string from mm/dd/yyyy to yyy-mm-dd
+# convert date string from mm/dd/yyyy to yyyy-mm-dd
 function mdy_to_ymd($date) {
        $date = ereg_replace('[^0-9/-]', '', $date);
        $date = ereg_replace('-', '/', $date);
@@ -81,7 +78,11 @@ function mdy_to_ymd($date) {
        switch(count($parts)) {
                case 1:
                        $year = $parts[0];
-                       list($month, $day) = explode('/', date('m/d'));
+                       if(strlen($year) == 0) {
+                               list($month, $day, $year) = explode('/', date('m/d/Y'));
+                       } else {
+                               list($month, $day) = explode('/', date('m/d'));
+                       }
                break;
                case 2:
                        list($month, $year) = $parts;
@@ -104,7 +105,11 @@ function ymd_to_mdy($date) {
        switch(count($parts)) {
                case 1:
                        $year = $parts[0];
-                       list($month, $day) = explode('-', date('m-d'));
+                       if(strlen($year) == 0) {
+                               list($year, $month, $day) = explode('-', date('Y-m-d'));
+                       } else {
+                               list($month, $day) = explode('-', date('m-d'));
+                       }
                break;
                case 2:
                        list($year, $month) = $parts;