X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fdate_functions.inc;h=e44f083b41d424c55f1589fab3e87c1510446e1b;hb=845a113be54da1b7a31ad093c68e1dffc9e11229;hp=484d5a8e1fc4072f59aab117c23b6f1cb50f1ac0;hpb=37f4a02e0f4bea58e5b2097d583bf9395ffc515f;p=fa-stable.git
diff --git a/includes/date_functions.inc b/includes/date_functions.inc
index 484d5a8e..e44f083b 100644
--- a/includes/date_functions.inc
+++ b/includes/date_functions.inc
@@ -1,5 +1,14 @@
.
+***********************************************************************/
/*
date validation and parsing functions
@@ -9,6 +18,8 @@ this can be a string either "d/m/Y" for UK/Australia/New Zealand dates or
"m/d/Y" for US/Canada format dates
*/
+if(function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get"))
+ @date_default_timezone_set(@date_default_timezone_get());
function __date($year, $month, $day)
{
@@ -83,7 +94,7 @@ function is_date($date_)
$year = substr($date_,0,4);
}
}
- if ((int)$year > 9999)
+ if (!isset($year)|| (int)$year > 9999)
{
return 0;
}
@@ -132,6 +143,19 @@ function Now()
else
return date("H:i");
}
+//
+// Retrieve and optionaly set default date for new document.
+//
+function new_doc_date($date=null)
+{
+ if (isset($date))
+ $_SESSION['_default_date'] = $date;
+
+ if (!isset($_SESSION['_default_date']) || !sticky_doc_date())
+ $_SESSION['_default_date'] = Today();
+
+ return $_SESSION['_default_date'];
+}
function is_date_in_fiscalyear($date, $convert=false)
{
@@ -338,6 +362,8 @@ and converts to a yyyy/mm/dd format */
$year = substr($date_,0,4);
}
}
+ else
+ $year = $month = $day = 0;
//to modify assumption in 2030
if ($date_system == 0)
@@ -359,7 +385,7 @@ and converts to a yyyy/mm/dd format */
list($year, $month, $day) = jalali_to_gregorian($year, $month, $day);
else if ($date_system == 2)
list($year, $month, $day) = islamic_to_gregorian($year, $month, $day);
- return $year."/".$month."/".$day;
+ return $year."-".$month."-".$day;
}// end of function
function date1_greater_date2 ($date1, $date2)
@@ -369,8 +395,8 @@ function date1_greater_date2 ($date1, $date2)
$date1 = date2sql($date1);
$date2 = date2sql($date2);
- list($year1, $month1, $day1) = explode("/", $date1);
- list($year2, $month2, $day2) = explode("/", $date2);
+ list($year1, $month1, $day1) = explode("-", $date1);
+ list($year2, $month2, $day2) = explode("-", $date2);
if ($year1 > $year2)
{
@@ -394,7 +420,7 @@ function date1_greater_date2 ($date1, $date2)
}
-function date_diff ($date1, $date2, $period)
+function date_diff2 ($date1, $date2, $period)
{
/* expects dates in the format specified in $DefaultDateFormat - period can be one of 'd','w','y','m'
@@ -403,8 +429,8 @@ provided that both dates are after 1970. Also only works for dates up to the yea
$date1 = date2sql($date1);
$date2 = date2sql($date2);
- list($year1, $month1, $day1) = explode("/", $date1);
- list($year2, $month2, $day2) = explode("/", $date2);
+ list($year1, $month1, $day1) = explode("-", $date1);
+ list($year2, $month2, $day2) = explode("-", $date2);
$stamp1 = mktime(0,0,0, (int)$month1, (int)$day1, (int)$year1);
$stamp2 = mktime(0,0,0, (int)$month2, (int)$day2, (int)$year2);
@@ -438,7 +464,7 @@ function explode_date_to_dmy($date_)
echo "
Dates must be entered in the format $disp. Sent was $date_
";
exit;
}
- list($year, $month, $day) = explode("/", $date);
+ list($year, $month, $day) = explode("-", $date);
return array($day, $month, $year);
}