2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
7 * Calculates, manipulates and retrieves dates
9 * It does not rely on 32-bit system time stamps, so it works dates
10 * before 1970 and after 2038.
12 * PHP versions 4 and 5
16 * Copyright (c) 1999-2006 Monte Ohrt, Pierre-Alain Joye, Daniel Convissor
17 * All rights reserved.
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted under the terms of the BSD License.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
35 * @category Date and Time
37 * @author Monte Ohrt <monte@ispi.net>
38 * @author Pierre-Alain Joye <pajoye@php.net>
39 * @author Daniel Convissor <danielc@php.net>
40 * @copyright 1999-2006 Monte Ohrt, Pierre-Alain Joye, Daniel Convissor
41 * @license http://www.opensource.org/licenses/bsd-license.php
43 * @version CVS: $Id: Calc.php,v 1.35 2006/11/21 23:01:13 firman Exp $
44 * @link http://pear.php.net/package/Date
45 * @since File available since Release 1.2
50 if (!defined('DATE_CALC_BEGIN_WEEKDAY')) {
52 * Defines what day starts the week
54 * Monday (1) is the international standard.
55 * Redefine this to 0 if you want weeks to begin on Sunday.
57 define('DATE_CALC_BEGIN_WEEKDAY', 1);
60 if (!defined('DATE_CALC_FORMAT')) {
62 * The default value for each method's $format parameter
64 * The default is '%Y%m%d'. To override this default, define
65 * this constant before including Calc.php.
67 * @since Constant available since Release 1.4.4
69 define('DATE_CALC_FORMAT', '%Y%m%d');
72 // {{{ Class: Date_Calc
75 * Calculates, manipulates and retrieves dates
77 * It does not rely on 32-bit system time stamps, so it works dates
78 * before 1970 and after 2038.
80 * @author Monte Ohrt <monte@ispi.net>
81 * @author Daniel Convissor <danielc@php.net>
82 * @copyright 1999-2006 Monte Ohrt, Pierre-Alain Joye, Daniel Convissor
83 * @license http://www.opensource.org/licenses/bsd-license.php
85 * @version Release: 1.4.7
86 * @link http://pear.php.net/package/Date
87 * @since Class available since Release 1.2
94 * Formats the date in the given format, much like strfmt()
96 * This function is used to alleviate the problem with 32-bit numbers for
97 * dates pre 1970 or post 2038, as strfmt() has on most systems.
98 * Most of the formatting options are compatible.
100 * Formatting options:
102 * %a abbreviated weekday name (Sun, Mon, Tue)
103 * %A full weekday name (Sunday, Monday, Tuesday)
104 * %b abbreviated month name (Jan, Feb, Mar)
105 * %B full month name (January, February, March)
106 * %d day of month (range 00 to 31)
107 * %e day of month, single digit (range 0 to 31)
108 * %E number of days since unspecified epoch (integer)
109 * (%E is useful for passing a date in a URL as
110 * an integer value. Then simply use
111 * daysToDate() to convert back to a date.)
112 * %j day of year (range 001 to 366)
113 * %m month as decimal number (range 1 to 12)
114 * %n newline character (\n)
115 * %t tab character (\t)
116 * %w weekday as decimal (0 = Sunday)
117 * %U week number of current year, first sunday as first week
118 * %y year as decimal (range 00 to 99)
119 * %Y year as decimal including century (range 0000 to 9999)
123 * @param int $day the day of the month
124 * @param int $month the month
125 * @param int $year the year. Use the complete year instead of the
126 * abbreviated version. E.g. use 2005, not 05.
127 * Do not add leading 0's for years prior to 1000.
128 * @param string $format the format string
130 * @return string the date in the desired format
135 function dateFormat($day, $month, $year, $format)
137 if (!Date_Calc
::isValidDate($day, $month, $year)) {
138 $year = Date_Calc
::dateNow('%Y');
139 $month = Date_Calc
::dateNow('%m');
140 $day = Date_Calc
::dateNow('%d');
145 for ($strpos = 0; $strpos < strlen($format); $strpos++
) {
146 $char = substr($format, $strpos, 1);
148 $nextchar = substr($format, $strpos +
1, 1);
151 $output .= Date_Calc
::getWeekdayAbbrname($day, $month, $year);
154 $output .= Date_Calc
::getWeekdayFullname($day, $month, $year);
157 $output .= Date_Calc
::getMonthAbbrname($month);
160 $output .= Date_Calc
::getMonthFullname($month);
163 $output .= sprintf('%02d', $day);
169 $output .= Date_Calc
::dateToDays($day, $month, $year);
172 $output .= Date_Calc
::julianDate($day, $month, $year);
175 $output .= sprintf('%02d', $month);
184 $output .= Date_Calc
::dayOfWeek($day, $month, $year);
187 $output .= Date_Calc
::weekOfYear($day, $month, $year);
190 $output .= substr($year, 2, 2);
199 $output .= $char.$nextchar;
210 // {{{ defaultCentury()
213 * Turns a two digit year into a four digit year
215 * From '51 to '99 is in the 1900's, otherwise it's in the 2000's.
217 * @param int $year the 2 digit year
219 * @return string the 4 digit year
224 function defaultCentury($year)
226 if (strlen($year) == 1) {
240 * Converts a date to number of days since a distant unspecified epoch
242 * @param int $day the day of the month
243 * @param int $month the month
244 * @param int $year the year. Use the complete year instead of the
245 * abbreviated version. E.g. use 2005, not 05.
246 * Do not add leading 0's for years prior to 1000.
248 * @return integer the number of days since the Date_Calc epoch
253 function dateToDays($day, $month, $year)
255 $century = (int)substr($year, 0, 2);
256 $year = (int)substr($year, 2, 2);
269 return (floor((146097 * $century) / 4 ) +
270 floor((1461 * $year) / 4 ) +
271 floor((153 * $month +
2) / 5 ) +
279 * Converts number of days to a distant unspecified epoch
281 * @param int $days the number of days since the Date_Calc epoch
282 * @param string $format the string indicating how to format the output
284 * @return string the date in the desired format
289 function daysToDate($days, $format = DATE_CALC_FORMAT
)
292 $century = floor((4 * $days - 1) / 146097);
293 $days = floor(4 * $days - 1 - 146097 * $century);
294 $day = floor($days / 4);
296 $year = floor((4 * $day +
3) / 1461);
297 $day = floor(4 * $day +
3 - 1461 * $year);
298 $day = floor(($day +
4) / 4);
300 $month = floor((5 * $day - 3) / 153);
301 $day = floor(5 * $day - 3 - 153 * $month);
302 $day = floor(($day +
5) / 5);
314 $century = sprintf('%02d', $century);
315 $year = sprintf('%02d', $year);
316 return Date_Calc
::dateFormat($day, $month, $century . $year, $format);
320 // {{{ gregorianToISO()
323 * Converts from Gregorian Year-Month-Day to ISO Year-WeekNumber-WeekDay
325 * Uses ISO 8601 definitions. Algorithm by Rick McCarty, 1999 at
326 * http://personal.ecu.edu/mccartyr/ISOwdALG.txt .
327 * Transcribed to PHP by Jesus M. Castagnetto.
329 * @param int $day the day of the month
330 * @param int $month the month
331 * @param int $year the year. Use the complete year instead of the
332 * abbreviated version. E.g. use 2005, not 05.
333 * Do not add leading 0's for years prior to 1000.
335 * @return string the date in ISO Year-WeekNumber-WeekDay format
340 function gregorianToISO($day, $month, $year)
342 $mnth = array (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334);
343 $y_isleap = Date_Calc
::isLeapYear($year);
344 $y_1_isleap = Date_Calc
::isLeapYear($year - 1);
345 $day_of_year_number = $day +
$mnth[$month - 1];
346 if ($y_isleap && $month > 2) {
347 $day_of_year_number++
;
349 // find Jan 1 weekday (monday = 1, sunday = 7)
350 $yy = ($year - 1) %
100;
351 $c = ($year - 1) - $yy;
352 $g = $yy +
intval($yy / 4);
353 $jan1_weekday = 1 +
intval((((($c / 100) %
4) * 5) +
$g) %
7);
354 // weekday for year-month-day
355 $h = $day_of_year_number +
($jan1_weekday - 1);
356 $weekday = 1 +
intval(($h - 1) %
7);
357 // find if Y M D falls in YearNumber Y-1, WeekNumber 52 or
358 if ($day_of_year_number <= (8 - $jan1_weekday) && $jan1_weekday > 4){
359 $yearnumber = $year - 1;
360 if ($jan1_weekday == 5 ||
($jan1_weekday == 6 && $y_1_isleap)) {
368 // find if Y M D falls in YearNumber Y+1, WeekNumber 1
369 if ($yearnumber == $year) {
375 if (($i - $day_of_year_number) < (4 - $weekday)) {
380 // find if Y M D falls in YearNumber Y, WeekNumber 1 through 53
381 if ($yearnumber == $year) {
382 $j = $day_of_year_number +
(7 - $weekday) +
($jan1_weekday - 1);
383 $weeknumber = intval($j / 7);
384 if ($jan1_weekday > 4) {
388 // put it all together
389 if ($weeknumber < 10) {
390 $weeknumber = '0'.$weeknumber;
392 return $yearnumber . '-' . $weeknumber . '-' . $weekday;
399 * Determines julian date of the given season
401 * Adapted from previous work in Java by James Mark Hamilton.
403 * @param string $season the season to get the date for: VERNALEQUINOX,
404 * SUMMERSOLSTICE, AUTUMNALEQUINOX,
406 * @param string $year the year in four digit format. Must be between
407 * -1000BC and 3000AD.
409 * @return float the julian date the season starts on
411 * @author James Mark Hamilton <mhamilton@qwest.net>
412 * @author Robert Butler <rob@maxwellcreek.org>
416 function dateSeason($season, $year = 0)
419 $year = Date_Calc
::dateNow('%Y');
421 if (($year >= -1000) && ($year <= 1000)) {
424 case 'VERNALEQUINOX':
425 $juliandate = (((((((-0.00071 * $y) - 0.00111) * $y) +
0.06134) * $y) +
365242.1374) * $y) +
1721139.29189;
427 case 'SUMMERSOLSTICE':
428 $juliandate = (((((((0.00025 * $y) +
0.00907) * $y) - 0.05323) * $y) +
365241.72562) * $y) +
1721233.25401;
430 case 'AUTUMNALEQUINOX':
431 $juliandate = (((((((0.00074 * $y) - 0.00297) * $y) - 0.11677) * $y) +
365242.49558) * $y) +
1721325.70455;
433 case 'WINTERSOLSTICE':
435 $juliandate = (((((((-0.00006 * $y) - 0.00933) * $y) - 0.00769) * $y) +
365242.88257) * $y) +
1721414.39987;
437 } elseif (($year > 1000) && ($year <= 3000)) {
438 $y = ($year - 2000) / 1000;
440 case 'VERNALEQUINOX':
441 $juliandate = (((((((-0.00057 * $y) - 0.00411) * $y) +
0.05169) * $y) +
365242.37404) * $y) +
2451623.80984;
443 case 'SUMMERSOLSTICE':
444 $juliandate = (((((((-0.0003 * $y) +
0.00888) * $y) +
0.00325) * $y) +
365241.62603) * $y) +
2451716.56767;
446 case 'AUTUMNALEQUINOX':
447 $juliandate = (((((((0.00078 * $y) +
0.00337) * $y) - 0.11575) * $y) +
365242.01767) * $y) +
2451810.21715;
449 case 'WINTERSOLSTICE':
451 $juliandate = (((((((0.00032 * $y) - 0.00823) * $y) - 0.06223) * $y) +
365242.74049) * $y) +
2451900.05952;
461 * Returns the current local date
463 * NOTE: This function retrieves the local date using strftime(),
464 * which may or may not be 32-bit safe on your system.
466 * @param string $format the string indicating how to format the output
468 * @return string the current date in the specified format
473 function dateNow($format = DATE_CALC_FORMAT
)
475 return strftime($format, time());
482 * Returns the current local year in format CCYY
484 * @return string the current year in four digit format
491 return Date_Calc
::dateNow('%Y');
498 * Returns the current local month in format MM
500 * @return string the current month in two digit format
507 return Date_Calc
::dateNow('%m');
514 * Returns the current local day in format DD
516 * @return string the current day of the month in two digit format
523 return Date_Calc
::dateNow('%d');
530 * Returns number of days since 31 December of year before given date
532 * @param int $day the day of the month, default is current local day
533 * @param int $month the month, default is current local month
534 * @param int $year the year in four digit format, default is current local year
536 * @return int the julian date for the date
541 function julianDate($day = 0, $month = 0, $year = 0)
544 $year = Date_Calc
::dateNow('%Y');
547 $month = Date_Calc
::dateNow('%m');
550 $day = Date_Calc
::dateNow('%d');
552 $days = array(0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334);
553 $julian = ($days[$month - 1] +
$day);
554 if ($month > 2 && Date_Calc
::isLeapYear($year)) {
561 // {{{ getWeekdayFullname()
564 * Returns the full weekday name for the given date
566 * @param int $day the day of the month, default is current local day
567 * @param int $month the month, default is current local month
568 * @param int $year the year in four digit format, default is current local year
570 * @return string the full name of the day of the week
575 function getWeekdayFullname($day = 0, $month = 0, $year = 0)
578 $year = Date_Calc
::dateNow('%Y');
581 $month = Date_Calc
::dateNow('%m');
584 $day = Date_Calc
::dateNow('%d');
586 $weekday_names = Date_Calc
::getWeekDays();
587 $weekday = Date_Calc
::dayOfWeek($day, $month, $year);
588 return $weekday_names[$weekday];
592 // {{{ getWeekdayAbbrname()
595 * Returns the abbreviated weekday name for the given date
597 * @param int $day the day of the month, default is current local day
598 * @param int $month the month, default is current local month
599 * @param int $year the year in four digit format, default is current local year
600 * @param int $length the length of abbreviation
602 * @return string the abbreviated name of the day of the week
606 * @see Date_Calc::getWeekdayFullname()
608 function getWeekdayAbbrname($day = 0, $month = 0, $year = 0, $length = 3)
611 $year = Date_Calc
::dateNow('%Y');
614 $month = Date_Calc
::dateNow('%m');
617 $day = Date_Calc
::dateNow('%d');
619 return substr(Date_Calc
::getWeekdayFullname($day, $month, $year),
624 // {{{ getMonthFullname()
627 * Returns the full month name for the given month
629 * @param int $month the month
631 * @return string the full name of the month
636 function getMonthFullname($month)
638 $month = (int)$month;
640 $month = (int)Date_Calc
::dateNow('%m');
642 $month_names = Date_Calc
::getMonthNames();
643 return $month_names[$month];
647 // {{{ getMonthAbbrname()
650 * Returns the abbreviated month name for the given month
652 * @param int $month the month
653 * @param int $length the length of abbreviation
655 * @return string the abbreviated name of the month
659 * @see Date_Calc::getMonthFullname
661 function getMonthAbbrname($month, $length = 3)
663 $month = (int)$month;
665 $month = Date_Calc
::dateNow('%m');
667 return substr(Date_Calc
::getMonthFullname($month), 0, $length);
671 // {{{ getMonthNames()
674 * Returns an array of month names
676 * Used to take advantage of the setlocale function to return
677 * language specific month names.
679 * TODO: cache values to some global array to avoid preformace
680 * hits when called more than once.
682 * @returns array an array of month names
687 function getMonthNames()
690 for ($i = 1; $i < 13; $i++
) {
691 $months[$i] = strftime('%B', mktime(0, 0, 0, $i, 1, 2001));
700 * Returns an array of week days
702 * Used to take advantage of the setlocale function to
703 * return language specific week days.
705 * TODO: cache values to some global array to avoid preformace
706 * hits when called more than once.
708 * @returns array an array of week day names
713 function getWeekDays()
716 for ($i = 0; $i < 7; $i++
) {
717 $weekdays[$i] = strftime('%A', mktime(0, 0, 0, 1, $i, 2001));
726 * Returns day of week for given date (0 = Sunday)
728 * @param int $day the day of the month, default is current local day
729 * @param int $month the month, default is current local month
730 * @param int $year the year in four digit format, default is current local year
732 * @return int the number of the day in the week
737 function dayOfWeek($day = 0, $month = 0, $year = 0)
740 $year = Date_Calc
::dateNow('%Y');
743 $month = Date_Calc
::dateNow('%m');
746 $day = Date_Calc
::dateNow('%d');
755 $day = (floor((13 * $month - 1) / 5) +
756 $day +
($year %
100) +
757 floor(($year %
100) / 4) +
758 floor(($year / 100) / 4) - 2 *
759 floor($year / 100) +
77);
761 $weekday_number = $day - 7 * floor($day / 7);
762 return $weekday_number;
769 * Returns week of the year, first Sunday is first day of first week
771 * @param int $day the day of the month, default is current local day
772 * @param int $month the month, default is current local month
773 * @param int $year the year in four digit format, default is current local year
775 * @return int the number of the week in the year
780 function weekOfYear($day = 0, $month = 0, $year = 0)
783 $year = Date_Calc
::dateNow('%Y');
786 $month = Date_Calc
::dateNow('%m');
789 $day = Date_Calc
::dateNow('%d');
791 $iso = Date_Calc
::gregorianToISO($day, $month, $year);
792 $parts = explode('-', $iso);
793 $week_number = intval($parts[1]);
798 // {{{ quarterOfYear()
801 * Returns quarter of the year for given date
803 * @param int $day the day of the month, default is current local day
804 * @param int $month the month, default is current local month
805 * @param int $year the year in four digit format, default is current local year
807 * @return int the number of the quarter in the year
812 function quarterOfYear($day = 0, $month = 0, $year = 0)
815 $year = Date_Calc
::dateNow('%Y');
818 $month = Date_Calc
::dateNow('%m');
821 $day = Date_Calc
::dateNow('%d');
823 $year_quarter = intval(($month - 1) / 3 +
1);
824 return $year_quarter;
831 * Find the number of days in the given month
833 * @param int $month the month, default is current local month
834 * @param int $year the year in four digit format, default is current local year
836 * @return int the number of days the month has
841 function daysInMonth($month = 0, $year = 0)
844 $year = Date_Calc
::dateNow('%Y');
847 $month = Date_Calc
::dateNow('%m');
850 if ($year == 1582 && $month == 10) {
851 return 21; // October 1582 only had 1st-4th and 15th-31st
855 if (Date_Calc
::isLeapYear($year)) {
860 } elseif ($month == 4 or $month == 6 or $month == 9 or $month == 11) {
868 // {{{ weeksInMonth()
871 * Returns the number of rows on a calendar month
873 * Useful for determining the number of rows when displaying a typical
876 * @param int $month the month, default is current local month
877 * @param int $year the year in four digit format, default is current local year
879 * @return int the number of weeks the month has
884 function weeksInMonth($month = 0, $year = 0)
887 $year = Date_Calc
::dateNow('%Y');
890 $month = Date_Calc
::dateNow('%m');
892 $FDOM = Date_Calc
::firstOfMonthWeekday($month, $year);
893 if (DATE_CALC_BEGIN_WEEKDAY
==1 && $FDOM==0) {
894 $first_week_days = 7 - $FDOM + DATE_CALC_BEGIN_WEEKDAY
;
896 } elseif (DATE_CALC_BEGIN_WEEKDAY
==0 && $FDOM == 6) {
897 $first_week_days = 7 - $FDOM + DATE_CALC_BEGIN_WEEKDAY
;
900 $first_week_days = DATE_CALC_BEGIN_WEEKDAY
- $FDOM;
903 $first_week_days %
= 7;
904 return ceil((Date_Calc
::daysInMonth($month, $year)
905 - $first_week_days) / 7) +
$weeks;
909 // {{{ getCalendarWeek()
912 * Return an array with days in week
914 * @param int $day the day of the month, default is current local day
915 * @param int $month the month, default is current local month
916 * @param int $year the year in four digit format, default is current local year
917 * @param string $format the string indicating how to format the output
919 * @return array $week[$weekday]
924 function getCalendarWeek($day = 0, $month = 0, $year = 0,
925 $format = DATE_CALC_FORMAT
)
928 $year = Date_Calc
::dateNow('%Y');
931 $month = Date_Calc
::dateNow('%m');
934 $day = Date_Calc
::dateNow('%d');
937 $week_array = array();
939 // date for the column of week
941 $curr_day = Date_Calc
::beginOfWeek($day, $month, $year,'%E');
943 for ($counter = 0; $counter <= 6; $counter++
) {
944 $week_array[$counter] = Date_Calc
::daysToDate($curr_day, $format);
951 // {{{ getCalendarMonth()
954 * Return a set of arrays to construct a calendar month for the given date
956 * @param int $month the month, default is current local month
957 * @param int $year the year in four digit format, default is current local year
958 * @param string $format the string indicating how to format the output
960 * @return array $month[$row][$col]
965 function getCalendarMonth($month = 0, $year = 0,
966 $format = DATE_CALC_FORMAT
)
969 $year = Date_Calc
::dateNow('%Y');
972 $month = Date_Calc
::dateNow('%m');
975 $month_array = array();
977 // date for the first row, first column of calendar month
978 if (DATE_CALC_BEGIN_WEEKDAY
== 1) {
979 if (Date_Calc
::firstOfMonthWeekday($month, $year) == 0) {
980 $curr_day = Date_Calc
::dateToDays('01', $month, $year) - 6;
982 $curr_day = Date_Calc
::dateToDays('01', $month, $year)
983 - Date_Calc
::firstOfMonthWeekday($month, $year) +
1;
986 $curr_day = (Date_Calc
::dateToDays('01', $month, $year)
987 - Date_Calc
::firstOfMonthWeekday($month, $year));
990 // number of days in this month
991 $daysInMonth = Date_Calc
::daysInMonth($month, $year);
993 $weeksInMonth = Date_Calc
::weeksInMonth($month, $year);
994 for ($row_counter = 0; $row_counter < $weeksInMonth; $row_counter++
) {
995 for ($column_counter = 0; $column_counter <= 6; $column_counter++
) {
996 $month_array[$row_counter][$column_counter] =
997 Date_Calc
::daysToDate($curr_day , $format);
1002 return $month_array;
1006 // {{{ getCalendarYear()
1009 * Return a set of arrays to construct a calendar year for the given date
1011 * @param int $year the year in four digit format, default current local year
1012 * @param string $format the string indicating how to format the output
1014 * @return array $year[$month][$row][$col]
1019 function getCalendarYear($year = 0, $format = DATE_CALC_FORMAT
)
1022 $year = Date_Calc
::dateNow('%Y');
1025 $year_array = array();
1027 for ($curr_month = 0; $curr_month <= 11; $curr_month++
) {
1028 $year_array[$curr_month] =
1029 Date_Calc
::getCalendarMonth($curr_month +
1,
1040 * Returns date of day before given date
1042 * @param int $day the day of the month, default is current local day
1043 * @param int $month the month, default is current local month
1044 * @param int $year the year in four digit format, default is current local year
1045 * @param string $format the string indicating how to format the output
1047 * @return string the date in the desired format
1052 function prevDay($day = 0, $month = 0, $year = 0,
1053 $format = DATE_CALC_FORMAT
)
1056 $year = Date_Calc
::dateNow('%Y');
1058 if (empty($month)) {
1059 $month = Date_Calc
::dateNow('%m');
1062 $day = Date_Calc
::dateNow('%d');
1064 $days = Date_Calc
::dateToDays($day, $month, $year);
1065 return Date_Calc
::daysToDate($days - 1, $format);
1072 * Returns date of day after given date
1074 * @param int $day the day of the month, default is current local day
1075 * @param int $month the month, default is current local month
1076 * @param int $year the year in four digit format, default is current local year
1077 * @param string $format the string indicating how to format the output
1079 * @return string the date in the desired format
1084 function nextDay($day = 0, $month = 0, $year = 0,
1085 $format = DATE_CALC_FORMAT
)
1088 $year = Date_Calc
::dateNow('%Y');
1090 if (empty($month)) {
1091 $month = Date_Calc
::dateNow('%m');
1094 $day = Date_Calc
::dateNow('%d');
1096 $days = Date_Calc
::dateToDays($day, $month, $year);
1097 return Date_Calc
::daysToDate($days +
1, $format);
1101 // {{{ prevWeekday()
1104 * Returns date of the previous weekday, skipping from Monday to Friday
1106 * @param int $day the day of the month, default is current local day
1107 * @param int $month the month, default is current local month
1108 * @param int $year the year in four digit format, default is current local year
1109 * @param string $format the string indicating how to format the output
1111 * @return string the date in the desired format
1116 function prevWeekday($day = 0, $month = 0, $year = 0,
1117 $format = DATE_CALC_FORMAT
)
1120 $year = Date_Calc
::dateNow('%Y');
1122 if (empty($month)) {
1123 $month = Date_Calc
::dateNow('%m');
1126 $day = Date_Calc
::dateNow('%d');
1128 $days = Date_Calc
::dateToDays($day, $month, $year);
1129 if (Date_Calc
::dayOfWeek($day, $month, $year) == 1) {
1131 } elseif (Date_Calc
::dayOfWeek($day, $month, $year) == 0) {
1136 return Date_Calc
::daysToDate($days, $format);
1140 // {{{ nextWeekday()
1143 * Returns date of the next weekday of given date, skipping from
1146 * @param int $day the day of the month, default is current local day
1147 * @param int $month the month, default is current local month
1148 * @param int $year the year in four digit format, default is current local year
1149 * @param string $format the string indicating how to format the output
1151 * @return string the date in the desired format
1156 function nextWeekday($day = 0, $month = 0, $year = 0,
1157 $format = DATE_CALC_FORMAT
)
1160 $year = Date_Calc
::dateNow('%Y');
1162 if (empty($month)) {
1163 $month = Date_Calc
::dateNow('%m');
1166 $day = Date_Calc
::dateNow('%d');
1168 $days = Date_Calc
::dateToDays($day, $month, $year);
1169 if (Date_Calc
::dayOfWeek($day, $month, $year) == 5) {
1171 } elseif (Date_Calc
::dayOfWeek($day, $month, $year) == 6) {
1176 return Date_Calc
::daysToDate($days, $format);
1180 // {{{ prevDayOfWeek()
1183 * Returns date of the previous specific day of the week
1184 * from the given date
1186 * @param int day of week, 0=Sunday
1187 * @param int $day the day of the month, default is current local day
1188 * @param int $month the month, default is current local month
1189 * @param int $year the year in four digit format, default is current local year
1190 * @param bool $onOrBefore if true and days are same, returns current day
1191 * @param string $format the string indicating how to format the output
1193 * @return string the date in the desired format
1198 function prevDayOfWeek($dow, $day = 0, $month = 0, $year = 0,
1199 $format = DATE_CALC_FORMAT
, $onOrBefore = false)
1202 $year = Date_Calc
::dateNow('%Y');
1204 if (empty($month)) {
1205 $month = Date_Calc
::dateNow('%m');
1208 $day = Date_Calc
::dateNow('%d');
1210 $days = Date_Calc
::dateToDays($day, $month, $year);
1211 $curr_weekday = Date_Calc
::dayOfWeek($day, $month, $year);
1212 if ($curr_weekday == $dow) {
1216 } elseif ($curr_weekday < $dow) {
1217 $days -= 7 - ($dow - $curr_weekday);
1219 $days -= $curr_weekday - $dow;
1221 return Date_Calc
::daysToDate($days, $format);
1225 // {{{ nextDayOfWeek()
1228 * Returns date of the next specific day of the week
1229 * from the given date
1231 * @param int $dow the day of the week (0 = Sunday)
1232 * @param int $day the day of the month, default is current local day
1233 * @param int $month the month, default is current local month
1234 * @param int $year the year in four digit format, default is current local year
1235 * @param bool $onOrAfter if true and days are same, returns current day
1236 * @param string $format the string indicating how to format the output
1238 * @return string the date in the desired format
1243 function nextDayOfWeek($dow, $day = 0, $month = 0, $year = 0,
1244 $format = DATE_CALC_FORMAT
, $onOrAfter = false)
1247 $year = Date_Calc
::dateNow('%Y');
1249 if (empty($month)) {
1250 $month = Date_Calc
::dateNow('%m');
1253 $day = Date_Calc
::dateNow('%d');
1256 $days = Date_Calc
::dateToDays($day, $month, $year);
1257 $curr_weekday = Date_Calc
::dayOfWeek($day, $month, $year);
1259 if ($curr_weekday == $dow) {
1263 } elseif ($curr_weekday > $dow) {
1264 $days +
= 7 - ($curr_weekday - $dow);
1266 $days +
= $dow - $curr_weekday;
1269 return Date_Calc
::daysToDate($days, $format);
1273 // {{{ prevDayOfWeekOnOrBefore()
1276 * Returns date of the previous specific day of the week
1277 * on or before the given date
1279 * @param int $dow the day of the week (0 = Sunday)
1280 * @param int $day the day of the month, default is current local day
1281 * @param int $month the month, default is current local month
1282 * @param int $year the year in four digit format, default is current local year
1283 * @param string $format the string indicating how to format the output
1285 * @return string the date in the desired format
1290 function prevDayOfWeekOnOrBefore($dow, $day = 0, $month = 0, $year = 0,
1291 $format = DATE_CALC_FORMAT
)
1293 return Date_Calc
::prevDayOfWeek($dow, $day, $month, $year, $format,
1298 // {{{ nextDayOfWeekOnOrAfter()
1301 * Returns date of the next specific day of the week
1302 * on or after the given date
1304 * @param int $dow the day of the week (0 = Sunday)
1305 * @param int $day the day of the month, default is current local day
1306 * @param int $month the month, default is current local month
1307 * @param int $year the year in four digit format, default is current local year
1308 * @param string $format the string indicating how to format the output
1310 * @return string the date in the desired format
1315 function nextDayOfWeekOnOrAfter($dow, $day = 0, $month = 0, $year = 0,
1316 $format = DATE_CALC_FORMAT
)
1318 return Date_Calc
::nextDayOfWeek($dow, $day, $month, $year, $format,
1323 // {{{ beginOfWeek()
1326 * Find the month day of the beginning of week for given date,
1327 * using DATE_CALC_BEGIN_WEEKDAY
1329 * Can return weekday of prev month.
1331 * @param int $day the day of the month, default is current local day
1332 * @param int $month the month, default is current local month
1333 * @param int $year the year in four digit format, default is current local year
1334 * @param string $format the string indicating how to format the output
1336 * @return string the date in the desired format
1341 function beginOfWeek($day = 0, $month = 0, $year = 0,
1342 $format = DATE_CALC_FORMAT
)
1345 $year = Date_Calc
::dateNow('%Y');
1347 if (empty($month)) {
1348 $month = Date_Calc
::dateNow('%m');
1351 $day = Date_Calc
::dateNow('%d');
1353 $this_weekday = Date_Calc
::dayOfWeek($day, $month, $year);
1354 $interval = (7 - DATE_CALC_BEGIN_WEEKDAY +
$this_weekday) %
7;
1355 return Date_Calc
::daysToDate(Date_Calc
::dateToDays($day, $month, $year)
1356 - $interval, $format);
1363 * Find the month day of the end of week for given date,
1364 * using DATE_CALC_BEGIN_WEEKDAY
1366 * Can return weekday of following month.
1368 * @param int $day the day of the month, default is current local day
1369 * @param int $month the month, default is current local month
1370 * @param int $year the year in four digit format, default is current local year
1371 * @param string $format the string indicating how to format the output
1373 * @return string the date in the desired format
1378 function endOfWeek($day = 0, $month = 0, $year = 0,
1379 $format = DATE_CALC_FORMAT
)
1382 $year = Date_Calc
::dateNow('%Y');
1384 if (empty($month)) {
1385 $month = Date_Calc
::dateNow('%m');
1388 $day = Date_Calc
::dateNow('%d');
1390 $this_weekday = Date_Calc
::dayOfWeek($day, $month, $year);
1391 $interval = (6 + DATE_CALC_BEGIN_WEEKDAY
- $this_weekday) %
7;
1392 return Date_Calc
::daysToDate(Date_Calc
::dateToDays($day, $month, $year)
1393 +
$interval, $format);
1397 // {{{ beginOfPrevWeek()
1400 * Find the month day of the beginning of week before given date,
1401 * using DATE_CALC_BEGIN_WEEKDAY
1403 * Can return weekday of prev month.
1405 * @param int $day the day of the month, default is current local day
1406 * @param int $month the month, default is current local month
1407 * @param int $year the year in four digit format, default is current local year
1408 * @param string $format the string indicating how to format the output
1410 * @return string the date in the desired format
1415 function beginOfPrevWeek($day = 0, $month = 0, $year = 0,
1416 $format = DATE_CALC_FORMAT
)
1419 $year = Date_Calc
::dateNow('%Y');
1421 if (empty($month)) {
1422 $month = Date_Calc
::dateNow('%m');
1425 $day = Date_Calc
::dateNow('%d');
1428 $date = Date_Calc
::daysToDate(Date_Calc
::dateToDays($day-7,
1433 $prev_week_year = substr($date, 0, 4);
1434 $prev_week_month = substr($date, 4, 2);
1435 $prev_week_day = substr($date, 6, 2);
1437 return Date_Calc
::beginOfWeek($prev_week_day, $prev_week_month,
1438 $prev_week_year, $format);
1442 // {{{ beginOfNextWeek()
1445 * Find the month day of the beginning of week after given date,
1446 * using DATE_CALC_BEGIN_WEEKDAY
1448 * Can return weekday of prev month.
1450 * @param int $day the day of the month, default is current local day
1451 * @param int $month the month, default is current local month
1452 * @param int $year the year in four digit format, default is current local year
1453 * @param string $format the string indicating how to format the output
1455 * @return string the date in the desired format
1460 function beginOfNextWeek($day = 0, $month = 0, $year = 0,
1461 $format = DATE_CALC_FORMAT
)
1464 $year = Date_Calc
::dateNow('%Y');
1466 if (empty($month)) {
1467 $month = Date_Calc
::dateNow('%m');
1470 $day = Date_Calc
::dateNow('%d');
1473 $date = Date_Calc
::daysToDate(Date_Calc
::dateToDays($day +
7,
1478 $next_week_year = substr($date, 0, 4);
1479 $next_week_month = substr($date, 4, 2);
1480 $next_week_day = substr($date, 6, 2);
1482 return Date_Calc
::beginOfWeek($next_week_day, $next_week_month,
1483 $next_week_year, $format);
1487 // {{{ beginOfMonth()
1490 * Return date of first day of month of given date
1492 * @param int $month the month, default is current local month
1493 * @param int $year the year in four digit format, default is current local year
1494 * @param string $format the string indicating how to format the output
1496 * @return string the date in the desired format
1500 * @see Date_Calc::beginOfMonthBySpan()
1501 * @deprecated Method deprecated in Release 1.4.4
1503 function beginOfMonth($month = 0, $year = 0, $format = DATE_CALC_FORMAT
)
1506 $year = Date_Calc
::dateNow('%Y');
1508 if (empty($month)) {
1509 $month = Date_Calc
::dateNow('%m');
1511 return Date_Calc
::dateFormat('01', $month, $year, $format);
1515 // {{{ beginOfPrevMonth()
1518 * Returns date of the first day of previous month of given date
1520 * @param int $day the day of the month, default is current local day
1521 * @param int $month the month, default is current local month
1522 * @param int $year the year in four digit format, default is current local year
1523 * @param string $format the string indicating how to format the output
1525 * @return string the date in the desired format
1529 * @see Date_Calc::beginOfMonthBySpan()
1530 * @deprecated Method deprecated in Release 1.4.4
1532 function beginOfPrevMonth($day = 0, $month = 0, $year = 0,
1533 $format = DATE_CALC_FORMAT
)
1536 $year = Date_Calc
::dateNow('%Y');
1538 if (empty($month)) {
1539 $month = Date_Calc
::dateNow('%m');
1542 $day = Date_Calc
::dateNow('%d');
1552 return Date_Calc
::dateFormat($day, $month, $year, $format);
1556 // {{{ endOfPrevMonth()
1559 * Returns date of the last day of previous month for given date
1561 * @param int $day the day of the month, default is current local day
1562 * @param int $month the month, default is current local month
1563 * @param int $year the year in four digit format, default is current local year
1564 * @param string $format the string indicating how to format the output
1566 * @return string the date in the desired format
1570 * @see Date_Calc::endOfMonthBySpan()
1571 * @deprecated Method deprecated in Release 1.4.4
1573 function endOfPrevMonth($day = 0, $month = 0, $year = 0,
1574 $format = DATE_CALC_FORMAT
)
1577 $year = Date_Calc
::dateNow('%Y');
1579 if (empty($month)) {
1580 $month = Date_Calc
::dateNow('%m');
1583 $day = Date_Calc
::dateNow('%d');
1591 $day = Date_Calc
::daysInMonth($month, $year);
1592 return Date_Calc
::dateFormat($day, $month, $year, $format);
1596 // {{{ beginOfNextMonth()
1599 * Returns date of begin of next month of given date
1601 * @param int $day the day of the month, default is current local day
1602 * @param int $month the month, default is current local month
1603 * @param int $year the year in four digit format, default is current local year
1604 * @param string $format the string indicating how to format the output
1606 * @return string the date in the desired format
1610 * @see Date_Calc::beginOfMonthBySpan()
1611 * @deprecated Method deprecated in Release 1.4.4
1613 function beginOfNextMonth($day = 0, $month = 0, $year = 0,
1614 $format = DATE_CALC_FORMAT
)
1617 $year = Date_Calc
::dateNow('%Y');
1619 if (empty($month)) {
1620 $month = Date_Calc
::dateNow('%m');
1623 $day = Date_Calc
::dateNow('%d');
1633 return Date_Calc
::dateFormat($day, $month, $year, $format);
1637 // {{{ endOfNextMonth()
1640 * Returns date of the last day of next month of given date
1642 * @param int $day the day of the month, default is current local day
1643 * @param int $month the month, default is current local month
1644 * @param int $year the year in four digit format, default is current local year
1645 * @param string $format the string indicating how to format the output
1647 * @return string the date in the desired format
1651 * @see Date_Calc::endOfMonthBySpan()
1652 * @deprecated Method deprecated in Release 1.4.4
1654 function endOfNextMonth($day = 0, $month = 0, $year = 0,
1655 $format = DATE_CALC_FORMAT
)
1658 $year = Date_Calc
::dateNow('%Y');
1660 if (empty($month)) {
1661 $month = Date_Calc
::dateNow('%m');
1664 $day = Date_Calc
::dateNow('%d');
1672 $day = Date_Calc
::daysInMonth($month, $year);
1673 return Date_Calc
::dateFormat($day, $month, $year, $format);
1677 // {{{ beginOfMonthBySpan()
1680 * Returns date of the first day of the month in the number of months
1681 * from the given date
1683 * @param int $months the number of months from the date provided.
1684 * Positive numbers go into the future.
1685 * Negative numbers go into the past.
1686 * 0 is the month presented in $month.
1687 * @param string $month the month, default is current local month
1688 * @param string $year the year in four digit format, default is the
1689 * current local year
1690 * @param string $format the string indicating how to format the output
1692 * @return string the date in the desired format
1696 * @since Method available since Release 1.4.4
1698 function beginOfMonthBySpan($months = 0, $month = 0, $year = 0,
1699 $format = DATE_CALC_FORMAT
)
1702 $year = Date_Calc
::dateNow('%Y');
1704 if (empty($month)) {
1705 $month = Date_Calc
::dateNow('%m');
1709 $tmp_mo = $month +
$months;
1710 $month = $tmp_mo %
12;
1713 $year = $year +
floor(($tmp_mo - 1) / 12);
1715 $year = $year +
floor($tmp_mo / 12);
1718 // past or present month
1719 $tmp_mo = $month +
$months;
1723 } elseif ($tmp_mo == 0) {
1728 // some time in a prior year
1729 $month = 12 +
($tmp_mo %
12);
1730 $year = $year +
floor($tmp_mo / 12);
1733 return Date_Calc
::dateFormat(1, $month, $year, $format);
1737 // {{{ endOfMonthBySpan()
1740 * Returns date of the last day of the month in the number of months
1741 * from the given date
1743 * @param int $months the number of months from the date provided.
1744 * Positive numbers go into the future.
1745 * Negative numbers go into the past.
1746 * 0 is the month presented in $month.
1747 * @param string $month the month, default is current local month
1748 * @param string $year the year in four digit format, default is the
1749 * current local year
1750 * @param string $format the string indicating how to format the output
1752 * @return string the date in the desired format
1756 * @since Method available since Release 1.4.4
1758 function endOfMonthBySpan($months = 0, $month = 0, $year = 0,
1759 $format = DATE_CALC_FORMAT
)
1762 $year = Date_Calc
::dateNow('%Y');
1764 if (empty($month)) {
1765 $month = Date_Calc
::dateNow('%m');
1769 $tmp_mo = $month +
$months;
1770 $month = $tmp_mo %
12;
1773 $year = $year +
floor(($tmp_mo - 1) / 12);
1775 $year = $year +
floor($tmp_mo / 12);
1778 // past or present month
1779 $tmp_mo = $month +
$months;
1783 } elseif ($tmp_mo == 0) {
1788 // some time in a prior year
1789 $month = 12 +
($tmp_mo %
12);
1790 $year = $year +
floor($tmp_mo / 12);
1793 return Date_Calc
::dateFormat(Date_Calc
::daysInMonth($month, $year),
1794 $month, $year, $format);
1798 // {{{ firstOfMonthWeekday()
1801 * Find the day of the week for the first of the month of given date
1803 * @param int $month the month, default is current local month
1804 * @param int $year the year in four digit format, default is current local year
1806 * @return int number of weekday for the first day, 0=Sunday
1811 function firstOfMonthWeekday($month = 0, $year = 0)
1814 $year = Date_Calc
::dateNow('%Y');
1816 if (empty($month)) {
1817 $month = Date_Calc
::dateNow('%m');
1819 return Date_Calc
::dayOfWeek('01', $month, $year);
1823 // {{{ NWeekdayOfMonth()
1826 * Calculates the date of the Nth weekday of the month,
1827 * such as the second Saturday of January 2000
1829 * @param int $week the number of the week to get
1830 * (1 = first, etc. Also can be 'last'.)
1831 * @param int $dow the day of the week (0 = Sunday)
1832 * @param int $month the month
1833 * @param int $year the year. Use the complete year instead of the
1834 * abbreviated version. E.g. use 2005, not 05.
1835 * Do not add leading 0's for years prior to 1000.
1836 * @param string $format the string indicating how to format the output
1838 * @return string the date in the desired format
1843 function NWeekdayOfMonth($week, $dow, $month, $year,
1844 $format = DATE_CALC_FORMAT
)
1846 if (is_numeric($week)) {
1847 $DOW1day = ($week - 1) * 7 +
1;
1848 $DOW1 = Date_Calc
::dayOfWeek($DOW1day, $month, $year);
1849 $wdate = ($week - 1) * 7 +
1 +
(7 +
$dow - $DOW1) %
7;
1850 if ($wdate > Date_Calc
::daysInMonth($month, $year)) {
1853 return Date_Calc
::dateFormat($wdate, $month, $year, $format);
1855 } elseif ($week == 'last' && $dow < 7) {
1856 $lastday = Date_Calc
::daysInMonth($month, $year);
1857 $lastdow = Date_Calc
::dayOfWeek($lastday, $month, $year);
1858 $diff = $dow - $lastdow;
1860 return Date_Calc
::dateFormat($lastday - (7 - $diff), $month,
1863 return Date_Calc
::dateFormat($lastday +
$diff, $month,
1872 // {{{ isValidDate()
1875 * Returns true for valid date, false for invalid date
1877 * @param int $day the day of the month
1878 * @param int $month the month
1879 * @param int $year the year. Use the complete year instead of the
1880 * abbreviated version. E.g. use 2005, not 05.
1881 * Do not add leading 0's for years prior to 1000.
1888 function isValidDate($day, $month, $year)
1890 if ($year < 0 ||
$year > 9999) {
1893 if (!checkdate($month, $day, $year)) {
1903 * Returns true for a leap year, else false
1905 * @param int $year the year. Use the complete year instead of the
1906 * abbreviated version. E.g. use 2005, not 05.
1907 * Do not add leading 0's for years prior to 1000.
1914 function isLeapYear($year = 0)
1917 $year = Date_Calc
::dateNow('%Y');
1919 if (preg_match('/\D/', $year)) {
1926 // pre Gregorio XIII - 1582
1927 return ($year %
4 == 0);
1929 // post Gregorio XIII - 1582
1930 return (($year %
4 == 0) && ($year %
100 != 0)) ||
($year %
400 == 0);
1935 // {{{ isFutureDate()
1938 * Determines if given date is a future date from now
1940 * @param int $day the day of the month
1941 * @param int $month the month
1942 * @param int $year the year. Use the complete year instead of the
1943 * abbreviated version. E.g. use 2005, not 05.
1944 * Do not add leading 0's for years prior to 1000.
1951 function isFutureDate($day, $month, $year)
1953 $this_year = Date_Calc
::dateNow('%Y');
1954 $this_month = Date_Calc
::dateNow('%m');
1955 $this_day = Date_Calc
::dateNow('%d');
1957 if ($year > $this_year) {
1959 } elseif ($year == $this_year) {
1960 if ($month > $this_month) {
1962 } elseif ($month == $this_month) {
1963 if ($day > $this_day) {
1975 * Determines if given date is a past date from now
1977 * @param int $day the day of the month
1978 * @param int $month the month
1979 * @param int $year the year. Use the complete year instead of the
1980 * abbreviated version. E.g. use 2005, not 05.
1981 * Do not add leading 0's for years prior to 1000.
1988 function isPastDate($day, $month, $year)
1990 $this_year = Date_Calc
::dateNow('%Y');
1991 $this_month = Date_Calc
::dateNow('%m');
1992 $this_day = Date_Calc
::dateNow('%d');
1994 if ($year < $this_year) {
1996 } elseif ($year == $this_year) {
1997 if ($month < $this_month) {
1999 } elseif ($month == $this_month) {
2000 if ($day < $this_day) {
2012 * Returns number of days between two given dates
2014 * @param int $day1 the day of the month
2015 * @param int $month1 the month
2016 * @param int $year1 the year. Use the complete year instead of the
2017 * abbreviated version. E.g. use 2005, not 05.
2018 * Do not add leading 0's for years prior to 1000.
2019 * @param int $day2 the day of the month
2020 * @param int $month2 the month
2021 * @param int $year2 the year. Use the complete year instead of the
2022 * abbreviated version. E.g. use 2005, not 05.
2023 * Do not add leading 0's for years prior to 1000.
2025 * @return int the absolute number of days between the two dates.
2026 * If an error occurs, -1 is returned.
2031 function dateDiff($day1, $month1, $year1, $day2, $month2, $year2)
2033 if (!Date_Calc
::isValidDate($day1, $month1, $year1)) {
2036 if (!Date_Calc
::isValidDate($day2, $month2, $year2)) {
2039 return abs(Date_Calc
::dateToDays($day1, $month1, $year1)
2040 - Date_Calc
::dateToDays($day2, $month2, $year2));
2044 // {{{ compareDates()
2047 * Compares two dates
2049 * @param int $day1 the day of the month
2050 * @param int $month1 the month
2051 * @param int $year1 the year. Use the complete year instead of the
2052 * abbreviated version. E.g. use 2005, not 05.
2053 * Do not add leading 0's for years prior to 1000.
2054 * @param int $day2 the day of the month
2055 * @param int $month2 the month
2056 * @param int $year2 the year. Use the complete year instead of the
2057 * abbreviated version. E.g. use 2005, not 05.
2058 * Do not add leading 0's for years prior to 1000.
2060 * @return int 0 if the dates are equal. 1 if date 1 is later, -1 if
2061 * date 1 is earlier.
2066 function compareDates($day1, $month1, $year1, $day2, $month2, $year2)
2068 $ndays1 = Date_Calc
::dateToDays($day1, $month1, $year1);
2069 $ndays2 = Date_Calc
::dateToDays($day2, $month2, $year2);
2070 if ($ndays1 == $ndays2) {
2073 return ($ndays1 > $ndays2) ?
1 : -1;
2086 * c-hanging-comment-ender-p: nil