37 public static function fraction($startDate, $endDate, $method = 0)
43 $sDate = self::excelBug($sDate, $startDate, $endDate, $method);
44 $eDate = self::excelBug($eDate, $endDate, $startDate, $method);
45 $startDate = min($sDate, $eDate);
46 $endDate = max($sDate, $eDate);
48 return $e->getMessage();
55 return self::method1($startDate, $endDate);
73 private static function excelBug(
float $sDate, $startDate, $endDate,
int $method): float
76 if ($endDate === null && $startDate !== null) {
88 private static function method1(
float $startDate,
float $endDate): float
93 $years = $endYear - $startYear + 1;
98 $startMonthDay = 100 * $startMonth + $startDay;
99 $endMonthDay = 100 * $endMonth + $endDay;
102 } elseif ($years == 2 && $startMonthDay >= $endMonthDay) {
104 $tmpCalcAnnualBasis = 365 + (int) ($startMonthDay <= 229);
106 $tmpCalcAnnualBasis = 365 + (int) ($endMonthDay >= 229);
108 $tmpCalcAnnualBasis = 365;
111 $tmpCalcAnnualBasis = 0;
112 for ($year = $startYear; $year <= $endYear; ++$year) {
115 $tmpCalcAnnualBasis /= $years;
118 return $days / $tmpCalcAnnualBasis;
static year($dateValue)
YEAR.
static interval($startDate, $endDate, $unit='D')
DATEDIF.
static month($dateValue)
MONTHOFYEAR.
static fraction($startDate, $endDate, $method=0)
YEARFRAC.
const COMPATIBILITY_OPENOFFICE
static isLeapYear($year)
Identify if a year is a leap year or not.
static getDateValue($dateValue, bool $allowBool=true)
getDateValue.
static between($startDate=0, $endDate=0, $method=false)
DAYS360.
static excelBug(float $sDate, $startDate, $endDate, int $method)
Excel 1900 calendar treats date argument of null as 1900-01-00.
static validateNumericNull($number)
Many functions accept null argument treated as 0.
static day($dateValue)
DAYOFMONTH.
static method1(float $startDate, float $endDate)
static getCompatibilityMode()
Return the current Compatibility Mode.