dbXapp
2.0
RAD, CMS, Module und Runtime-IDE fuer dbXapp
Toggle main menu visibility
Loading...
Searching...
No Matches
dbxDateTime.class.php
Go to the documentation of this file.
1
<?php
2
3
class
dbxDateTime
{
4
5
public
$holidays
=array();
6
7
function
init
() {
8
$holidays
= [
9
'2024-01-01'
,
// Neujahr
10
'2024-12-25'
,
// Weihnachten
11
'2024-12-26'
,
// Zweiter Weihnachtsfeiertag
12
// Weitere Feiertage hinzufügen
13
];
14
$this->holidays=
$holidays
;
15
16
}
17
18
19
function
get_NextWorkingDay
(DateTime $date): DateTime {
20
// Feiertage in ein Array von DateTime-Objekten umwandeln
21
$holiday = $this->holidays;
22
$holidayDates = array_map(
function
($holiday) {
23
return
new
DateTime($holiday);
24
},
$holidays
);
25
26
do
{
27
// Ein Tag hinzufügen
28
$date->modify(
'+1 day'
);
29
30
// Prüfen, ob der Tag ein Wochenende oder ein Feiertag ist
31
}
while
(in_array($date->format(
'N'
), [
'6'
,
'7'
]) || in_array($date->format(
'Y-m-d'
), array_map(
function
($holiday) {
32
return
$holiday->format(
'Y-m-d'
);
33
}, $holidayDates)));
34
35
return
$date;
36
}
37
38
39
// Beispiel-Feiertage
40
//$date = new DateTime();
41
//$nextWorkingDay = getNextWorkingDay($date, $holidays);
42
//echo "Der nächste Arbeitstag ist: " . $nextWorkingDay->format('Y-m-d');
43
44
45
}
dbxDateTime
Definition
dbxDateTime.class.php:3
dbxDateTime\init
init()
Definition
dbxDateTime.class.php:7
dbxDateTime\$holidays
$holidays
Definition
dbxDateTime.class.php:5
dbxDateTime\get_NextWorkingDay
get_NextWorkingDay(DateTime $date)
Definition
dbxDateTime.class.php:19
dbx
include
dbxDateTime.class.php
Generated by
1.17.0