39 public static function between($startDate = 0, $endDate = 0, $method =
false)
45 return $e->getMessage();
48 if (!is_bool($method)) {
53 $PHPStartDateObject = SharedDateHelper::excelToDateTimeObject($startDate);
54 $startDay = $PHPStartDateObject->format(
'j');
55 $startMonth = $PHPStartDateObject->format(
'n');
56 $startYear = $PHPStartDateObject->format(
'Y');
58 $PHPEndDateObject = SharedDateHelper::excelToDateTimeObject($endDate);
59 $endDay = $PHPEndDateObject->format(
'j');
60 $endMonth = $PHPEndDateObject->format(
'n');
61 $endYear = $PHPEndDateObject->format(
'Y');
63 return self::dateDiff360((
int) $startDay, (
int) $startMonth, (
int) $startYear, (
int) $endDay, (
int) $endMonth, (
int) $endYear, !$method);
69 private static function dateDiff360(
int $startDay,
int $startMonth,
int $startYear,
int $endDay,
int $endMonth,
int $endYear,
bool $methodUS): int
71 $startDay = self::getStartDay($startDay, $startMonth, $startYear, $methodUS);
72 $endDay = self::getEndDay($endDay, $endMonth, $endYear, $startDay, $methodUS);
74 return $endDay + $endMonth * 30 + $endYear * 360 - $startDay - $startMonth * 30 - $startYear * 360;
77 private static function getStartDay(
int $startDay,
int $startMonth,
int $startYear,
bool $methodUS): int
79 if ($startDay == 31) {
81 } elseif ($methodUS && ($startMonth == 2 && ($startDay == 29 || ($startDay == 28 && !
Helpers::isLeapYear($startYear))))) {
88 private static function getEndDay(
int $endDay,
int &$endMonth,
int &$endYear,
int $startDay,
bool $methodUS): int
91 if ($methodUS && $startDay != 30) {
93 if ($endMonth == 12) {
static getStartDay(int $startDay, int $startMonth, int $startYear, bool $methodUS)
static getEndDay(int $endDay, int &$endMonth, int &$endYear, int $startDay, bool $methodUS)
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 dateDiff360(int $startDay, int $startMonth, int $startYear, int $endDay, int $endMonth, int $endYear, bool $methodUS)
Return the number of days between two dates based on a 360 day calendar.