39 -11 =>
"Pacific/Pago_Pago",
40 -10 =>
"Pacific/Honolulu",
41 -9 =>
"America/Anchorage",
42 -8 =>
"America/Los_Angeles",
43 -7 =>
"America/Dawson_Creek",
44 -6 =>
"America/Chicago",
45 -5 =>
"America/Bogota",
46 -4 =>
"America/Asuncion",
47 -3 =>
"America/Araguaina",
48 -2 =>
"America/Noronha",
49 -1 =>
"Atlantic/Azores",
52 2 =>
"Europe/Helsinki",
58 8 =>
"Asia/Hong_Kong",
60 10 =>
"Australia/Sydney",
61 11 =>
"Pacific/Noumea",
62 12 =>
"Pacific/Auckland",
63 13 =>
"Pacific/Fakaofo",
64 14 =>
"Pacific/Kiritimati"
77 return @date_default_timezone_get();
88 if (method_exists(
'DateTimeZone',
'getOffset')) {
94 if ($refgmtdate ==
'now') {
95 $newrefgmtdate = $yearref.
'-'.$monthref.
'-'.$dayref;
96 } elseif ($refgmtdate ==
'summer') {
97 $newrefgmtdate = $yearref.
'-08-01';
99 $newrefgmtdate = $yearref.
'-01-01';
101 $newrefgmtdate .=
'T00:00:00+00:00';
103 $localdt =
new DateTime($newrefgmtdate, $localtz);
104 $tmp = -1 * $localtz->getOffset($localdt);
110 $tz = round(($tmp < 0 ? 1 : -1) * abs($tmp / 3600));
127 if (empty($duration_value)) {
130 if ($duration_unit ==
's') {
131 return $time + (int) ($duration_value);
133 if ($duration_unit ==
'i' || $duration_unit ==
'mn' || $duration_unit ==
'min') {
134 return $time + (int) (60 * $duration_value);
136 if ($duration_unit ==
'h') {
137 return $time + (int) (3600 * $duration_value);
139 if ($duration_unit ==
'w') {
140 return $time + (int) (3600 * 24 * 7 * $duration_value);
147 if ($duration_value > 0) {
148 $deltastring .= abs($duration_value);
151 if ($duration_value < 0) {
152 $deltastring .= abs($duration_value);
155 if ($duration_unit ==
'd') {
158 if ($duration_unit ==
'm') {
161 if ($duration_unit ==
'y') {
165 $date =
new DateTime();
167 $date->setTimezone(
new DateTimeZone(
'UTC'));
169 $date->setTimestamp($time);
170 $interval =
new DateInterval($deltastring);
173 $date->sub($interval);
175 $date->add($interval);
178 if ($ruleforendofmonth == 1 && $duration_unit ==
'm') {
181 $timetotalmonths = (($timeyear * 12) + $timemonth);
183 $monthsexpected = ($timetotalmonths + $duration_value);
185 $newtime = $date->getTimestamp();
189 $newtimetotalmonths = (($newtimeyear * 12) + $newtimemonth);
191 if ($monthsexpected < $newtimetotalmonths) {
196 $datelim =
dol_mktime($newtimehours, $newtimemins, $newtimesecs, $newtimemonth, 1, $newtimeyear);
197 $datelim -= (3600 * 24);
199 $date->setTimestamp($datelim);
202 return $date->getTimestamp();
217 $iResult = ((int) $iHours * 3600) + ((int) $iMinutes * 60) + (int) $iSeconds;
248 if (empty($lengthOfDay)) {
249 $lengthOfDay = 86400;
251 if (empty($lengthOfWeek)) {
254 $nbHbyDay = $lengthOfDay / 3600;
258 if ($format ==
'all' || $format ==
'allwithouthour' || $format ==
'allhour' || $format ==
'allhourmin' || $format ==
'allhourminsec') {
259 if ((
int) $iSecond === 0) {
266 if ($iSecond >= $lengthOfDay) {
267 for ($i = $iSecond; $i >= $lengthOfDay; $i -= $lengthOfDay) {
269 $iSecond -= $lengthOfDay;
271 $dayTranslate = $langs->trans(
"Day");
272 if ($iSecond >= ($lengthOfDay * 2)) {
273 $dayTranslate = $langs->trans(
"Days");
277 if ($lengthOfWeek < 7) {
279 if ($sDay >= $lengthOfWeek) {
280 $sWeek = (int) (($sDay - $sDay % $lengthOfWeek) / $lengthOfWeek);
281 $sDay %= $lengthOfWeek;
282 $weekTranslate = $langs->trans(
"DurationWeek");
284 $weekTranslate = $langs->trans(
"DurationWeeks");
286 $sTime .= $sWeek.
' '.$weekTranslate.
' ';
291 $dayTranslate = $langs->trans(
"Day");
293 $dayTranslate = $langs->trans(
"Days");
295 $sTime .= $sDay.
' '.$langs->trans(
"d").
' ';
298 if ($format ==
'all') {
299 if ($iSecond || empty($sDay)) {
302 } elseif ($format ==
'allhourminsec') {
303 return sprintf(
"%02d", ($sWeek * $lengthOfWeek * $nbHbyDay + $sDay * $nbHbyDay + (
int) floor($iSecond / 3600))).
':'.sprintf(
"%02d", ((
int) floor(($iSecond % 3600) / 60))).
':'.sprintf(
"%02d", ((
int) ($iSecond % 60)));
304 } elseif ($format ==
'allhourmin') {
305 return sprintf(
"%02d", ($sWeek * $lengthOfWeek * $nbHbyDay + $sDay * $nbHbyDay + (
int) floor($iSecond / 3600))).
':'.sprintf(
"%02d", ((
int) floor(($iSecond % 3600) / 60)));
306 } elseif ($format ==
'allhour') {
307 return sprintf(
"%02d", ($sWeek * $lengthOfWeek * $nbHbyDay + $sDay * $nbHbyDay + (
int) floor($iSecond / 3600)));
309 } elseif ($format ==
'hour') {
311 } elseif ($format ==
'fullhour') {
312 if (!empty($iSecond)) {
318 } elseif ($format ==
'min') {
320 } elseif ($format ==
'sec') {
322 } elseif ($format ==
'month') {
324 } elseif ($format ==
'year') {
327 return trim((
string) $sTime);
342 if ($duration_unit ==
's') {
343 $result = $duration_value / 3600;
345 if ($duration_unit ==
'i' || $duration_unit ==
'mn' || $duration_unit ==
'min') {
346 $result = $duration_value / 60;
348 if ($duration_unit ==
'h') {
349 $result = $duration_value;
351 if ($duration_unit ==
'd') {
352 $result = $duration_value * 24;
354 if ($duration_unit ==
'w') {
355 $result = $duration_value * 24 * 7;
357 if ($duration_unit ==
'm') {
358 $result = $duration_value * 730.484;
360 if ($duration_unit ==
'y') {
361 $result = $duration_value * 365 * 24;
382function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand = 0, $gm =
false)
387 $day_date = intval($day_date);
388 $month_date = intval($month_date);
389 $year_date = intval($year_date);
391 if ($month_date > 0) {
392 if ($month_date > 12) {
395 if ($year_date > 0 && empty($day_date)) {
396 $sqldate .= ($excludefirstand ?
"" :
" AND ").$datefield.
" BETWEEN '".$db->idate(
dol_get_first_day($year_date, $month_date, $gm));
397 $sqldate .=
"' AND '".$db->idate(
dol_get_last_day($year_date, $month_date, $gm)).
"'";
398 } elseif ($year_date > 0 && !empty($day_date)) {
399 $sqldate .= ($excludefirstand ?
"" :
" AND ").$datefield.
" BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month_date, $day_date, $year_date, $gm));
400 $sqldate .=
"' AND '".$db->idate(
dol_mktime(23, 59, 59, $month_date, $day_date, $year_date, $gm)).
"'";
403 $sqldate .= ($excludefirstand ?
"" :
" AND ").
" date_format( ".$datefield.
", '%c') = '".$db->escape($month_date).
"'";
405 } elseif ($year_date > 0) {
406 $sqldate .= ($excludefirstand ?
"" :
" AND ").$datefield.
" BETWEEN '".$db->idate(
dol_get_first_day($year_date, 1, $gm));
407 $sqldate .=
"' AND '".$db->idate(
dol_get_last_day($year_date, 12, $gm)).
"'";
435 if (preg_match(
'/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $string, $reg)) {
436 dol_syslog(
"dol_stringtotime call to function with deprecated parameter format", LOG_WARNING);
439 $sday = (int) $reg[1];
440 $smonth = (int) $reg[2];
441 $syear = (int) $reg[3];
442 $shour = (int) $reg[4];
443 $smin = (int) $reg[5];
444 $ssec = (int) $reg[6];
448 if ($syear >= 50 && $syear < 100) {
451 $string = sprintf(
"%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec);
452 } elseif (preg_match(
'/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z$/i', $string, $reg)
453 || preg_match(
'/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/i', $string, $reg)
454 || preg_match(
'/^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z$/i', $string, $reg)
456 $syear = (int) $reg[1];
457 $smonth = (int) $reg[2];
458 $sday = (int) $reg[3];
459 $shour = (int) $reg[4];
460 $smin = (int) $reg[5];
461 $ssec = (int) $reg[6];
462 $string = sprintf(
"%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec);
465 $string = preg_replace(
'/([^0-9])/i',
'', $string);
466 $tmp = $string.
'000000';
470 } elseif (empty($gm) || $gm ===
'tzserver') {
474 $date =
dol_mktime((
int) substr($tmp, 8, 2), (
int) substr($tmp, 10, 2), (
int) substr($tmp, 12, 2), (
int) substr($tmp, 4, 2), (
int) substr($tmp, 6, 2), (
int) substr($tmp, 0, 4), $gm);
490 $time =
dol_mktime(12, 0, 0, $month, $day, $year, 1, 0);
491 $time -= 24 * 60 * 60;
493 return array(
'year' => $tmparray[
'year'],
'month' => $tmparray[
'mon'],
'day' => $tmparray[
'mday']);
506 $time =
dol_mktime(12, 0, 0, $month, $day, $year, 1, 0);
507 $time += 24 * 60 * 60;
509 return array(
'year' => $tmparray[
'year'],
'month' => $tmparray[
'mon'],
'day' => $tmparray[
'mday']);
523 $prev_year = $year - 1;
525 $prev_month = $month - 1;
528 return array(
'year' => $prev_year,
'month' => $prev_month);
542 $next_year = $year + 1;
544 $next_month = $month + 1;
547 return array(
'year' => $next_year,
'month' => $next_month);
563 $time =
dol_mktime(12, 0, 0, $month, $tmparray[
'first_day'], $year, 1, 0);
564 $time -= 24 * 60 * 60 * 7;
566 return array(
'year' => $tmparray[
'year'],
'month' => $tmparray[
'mon'],
'day' => $tmparray[
'mday']);
582 $time =
dol_mktime(12, 0, 0, $tmparray[
'first_month'], $tmparray[
'first_day'], $tmparray[
'first_year'], 1, 0);
583 $time += 24 * 60 * 60 * 7;
586 return array(
'year' => $tmparray[
'year'],
'month' => $tmparray[
'mon'],
'day' => $tmparray[
'mday']);
605 return dol_mktime(0, 0, 0, $month, 1, $year, $gm);
632 $datelim =
dol_mktime(23, 59, 59, $month, 1, $year, $gm);
633 $datelim -= (3600 * 24);
648 $tmparray =
dol_getdate($date,
false, ($gm ==
'gmt' ?
'gmt' :
''));
649 return dol_mktime(23, 59, 59, $tmparray[
'mon'], $tmparray[
'mday'], $tmparray[
'year'], $gm);
662 $tmparray =
dol_getdate($date,
false, ($gm ==
'gmt' ?
'gmt' :
''));
663 return dol_mktime(0, 0, 0, $tmparray[
'mon'], $tmparray[
'mday'], $tmparray[
'year'], $gm);
680 $date =
dol_mktime(0, 0, 0, $month, $day, $year, $gm);
683 $start_week = (isset(
$conf->global->MAIN_START_WEEK) ?
$conf->global->MAIN_START_WEEK : 1);
688 $days = $start_week - $tmparray[
'wday'];
693 $seconds = $days * 24 * 60 * 60;
697 $tmpdaytms = (int) date((
string) $tmparray[
'0']) - $seconds;
698 $tmpday = idate(
"d", $tmpdaytms);
701 if ($tmpday > $day) {
702 $prev_month = $month - 1;
705 if ($prev_month == 0) {
707 $prev_year = $year - 1;
710 $prev_month = $month;
713 $tmpmonth = $prev_month;
714 $tmpyear = $prev_year;
717 $tmptime =
dol_mktime(12, 0, 0, $month, $tmpday, $year, 1, 0);
718 $tmptime -= 24 * 60 * 60 * 7;
720 $prev_day = $tmparray[
'mday'];
723 if ($prev_day > $tmpday) {
724 $prev_month = $month - 1;
727 if ($prev_month == 0) {
729 $prev_year = $year - 1;
733 $week = date(
"W",
dol_mktime(0, 0, 0, $tmpmonth, $tmpday, $tmpyear, $gm));
735 return array(
'year' => $year,
'month' => $month,
'week' => $week,
'first_day' => $tmpday,
'first_month' => $tmpmonth,
'first_year' => $tmpyear,
'prev_year' => $prev_year,
'prev_month' => $prev_month,
'prev_day' => $prev_day);
747 $base =
new DateTime(
"$year-03-21",
new DateTimeZone(
"UTC"));
748 $days = easter_days($year);
749 $tmp = $base->add(
new DateInterval(
"P{$days}D"));
750 return $tmp->getTimestamp();
769function num_public_holiday($timestampStart, $timestampEnd, $country_code =
'', $lastday = 0, $includesaturday = -1, $includesunday = -1, $includefriday = -1, $includemonday = -1)
771 global
$conf, $db, $mysoc;
776 if (($timestampEnd - $timestampStart) % 86400 != 0) {
777 return 'Error Dates must use same hours and must be GMT dates';
780 if (empty($country_code)) {
781 $country_code = $mysoc->country_code;
783 if ($includemonday < 0) {
784 $includemonday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY', 0);
786 if ($includefriday < 0) {
787 $includefriday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY', 0);
789 if ($includesaturday < 0) {
790 $includesaturday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY', 1);
792 if ($includesunday < 0) {
793 $includesunday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY', 1);
796 $country_id =
dol_getIdFromCode($db, $country_code,
'c_country',
'code',
'rowid');
798 if (empty(
$conf->cache[
'arrayOfActivePublicHolidays_'.$country_id])) {
800 $tmpArrayOfPublicHolidays = array();
801 $sql =
"SELECT id, code, entity, fk_country, dayrule, year, month, day, active";
802 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_hrm_public_holiday";
803 $sql .=
" WHERE active = 1 and fk_country IN (0".($country_id > 0 ?
", ".$country_id : 0).
")";
804 $sql .=
" AND entity IN (0," .getEntity(
'holiday') .
")";
806 $resql = $db->query($sql);
808 $num_rows = $db->num_rows($resql);
810 while ($i < $num_rows) {
811 $obj = $db->fetch_object($resql);
812 $tmpArrayOfPublicHolidays[$obj->id] = array(
'dayrule' => $obj->dayrule,
'year' => $obj->year,
'month' => $obj->month,
'day' => $obj->day);
817 return 'Error sql '.$db->lasterror();
821 $conf->cache[
'arrayOfActivePublicHolidays_'.$country_id] = $tmpArrayOfPublicHolidays;
824 $arrayOfPublicHolidays =
$conf->cache[
'arrayOfActivePublicHolidays_'.$country_id];
827 while ((($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd))
830 $specialdayrule = array();
832 $jour = (int) gmdate(
"d", $timestampStart);
833 $mois = (int) gmdate(
"m", $timestampStart);
834 $annee = (int) gmdate(
"Y", $timestampStart);
837 foreach ($arrayOfPublicHolidays as $entrypublicholiday) {
838 if (!empty($entrypublicholiday[
'dayrule']) && $entrypublicholiday[
'dayrule'] !=
'date') {
839 $specialdayrule[$entrypublicholiday[
'dayrule']] = $entrypublicholiday[
'dayrule'];
842 if (!empty($entrypublicholiday[
'year']) && $entrypublicholiday[
'year'] != $annee) {
845 if ($entrypublicholiday[
'month'] != $mois) {
848 if ($entrypublicholiday[
'day'] != $jour) {
864 if (in_array(
'easter', $specialdayrule)) {
867 $jour_paques = gmdate(
"d", $date_paques);
868 $mois_paques = gmdate(
"m", $date_paques);
869 if ($jour_paques == $jour && $mois_paques == $mois) {
875 if (in_array(
'eastermonday', $specialdayrule)) {
879 $date_lundi_paques = $date_paques + (3600 * 24);
880 $jour_lundi_paques = gmdate(
"d", $date_lundi_paques);
881 $mois_lundi_paques = gmdate(
"m", $date_lundi_paques);
882 if ($jour_lundi_paques == $jour && $mois_lundi_paques == $mois) {
890 if (in_array(
'goodfriday', $specialdayrule)) {
895 $date_good_friday = $easter - (2 * 3600 * 24);
896 $dom_good_friday = gmdate(
"d", $date_good_friday);
897 $month_good_friday = gmdate(
"m", $date_good_friday);
899 if ($dom_good_friday == $jour && $month_good_friday == $mois) {
904 if (in_array(
'ascension', $specialdayrule)) {
907 $date_ascension = $date_paques + (3600 * 24 * 39);
908 $jour_ascension = gmdate(
"d", $date_ascension);
909 $mois_ascension = gmdate(
"m", $date_ascension);
910 if ($jour_ascension == $jour && $mois_ascension == $mois) {
916 if (in_array(
'pentecost', $specialdayrule)) {
919 $date_pentecote = $date_paques + (3600 * 24 * 49);
920 $jour_pentecote = gmdate(
"d", $date_pentecote);
921 $mois_pentecote = gmdate(
"m", $date_pentecote);
922 if ($jour_pentecote == $jour && $mois_pentecote == $mois) {
927 if (in_array(
'pentecotemonday', $specialdayrule)) {
930 $date_pentecote = $date_paques + (3600 * 24 * 50);
931 $jour_pentecote = gmdate(
"d", $date_pentecote);
932 $mois_pentecote = gmdate(
"m", $date_pentecote);
933 if ($jour_pentecote == $jour && $mois_pentecote == $mois) {
939 if (in_array(
'viernessanto', $specialdayrule)) {
942 $date_viernes = $date_paques - (3600 * 24 * 2);
943 $jour_viernes = gmdate(
"d", $date_viernes);
944 $mois_viernes = gmdate(
"m", $date_viernes);
945 if ($jour_viernes == $jour && $mois_viernes == $mois) {
951 if (in_array(
'fronleichnam', $specialdayrule)) {
954 $date_fronleichnam = $date_paques + (3600 * 24 * 60);
955 $jour_fronleichnam = gmdate(
"d", $date_fronleichnam);
956 $mois_fronleichnam = gmdate(
"m", $date_fronleichnam);
957 if ($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) {
963 if (in_array(
'genevafast', $specialdayrule)) {
965 $date_1sunsept = strtotime(
'next thursday', strtotime(
'next sunday', mktime(0, 0, 0, 9, 1, $annee)));
966 $jour_1sunsept = date(
"d", $date_1sunsept);
967 $mois_1sunsept = date(
"m", $date_1sunsept);
968 if ($jour_1sunsept == $jour && $mois_1sunsept == $mois) {
978 if ($includefriday || $includesaturday || $includesunday) {
979 $jour_julien = unixtojd($timestampStart);
980 $jour_semaine = jddayofweek($jour_julien, 0);
981 if ($includefriday) {
982 if ($jour_semaine == 5) {
986 if ($includesaturday) {
987 if ($jour_semaine == 6) {
991 if ($includesunday) {
992 if ($jour_semaine == 0) {
1028 if ($timestampStart <= $timestampEnd) {
1029 if ($lastday == 1) {
1034 $nbjours = (int) floor(($timestampEnd - $timestampStart) / (60 * 60 * 24)) + 1 - $bit;
1054function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0, $halfday = 0, $country_code =
'')
1056 global $langs, $mysoc;
1058 if (empty($country_code)) {
1059 $country_code = $mysoc->country_code;
1062 dol_syslog(
'num_open_day timestampStart='.$timestampStart.
' timestampEnd='.$timestampEnd.
' bit='.$lastday.
' country_code='.$country_code);
1065 if (!is_int($timestampStart) && !is_float($timestampStart)) {
1066 return 'ErrorBadParameter_num_open_day';
1068 if (!is_int($timestampEnd) && !is_float($timestampEnd)) {
1069 return 'ErrorBadParameter_num_open_day';
1073 if ($timestampStart < $timestampEnd) {
1076 $numholidays =
num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday);
1077 $nbOpenDay = ($numdays - $numholidays);
1078 if ($inhour == 1 && $nbOpenDay <= 3) {
1081 return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
1082 } elseif ($timestampStart == $timestampEnd) {
1085 $numholidays =
num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday);
1086 if ($numholidays == 1) {
1091 $nbOpenDay = $lastday;
1096 return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
1098 return $langs->trans(
"Error");
1114 $montharray = array(
1115 1 => $outputlangs->trans(
"Month01"),
1116 2 => $outputlangs->trans(
"Month02"),
1117 3 => $outputlangs->trans(
"Month03"),
1118 4 => $outputlangs->trans(
"Month04"),
1119 5 => $outputlangs->trans(
"Month05"),
1120 6 => $outputlangs->trans(
"Month06"),
1121 7 => $outputlangs->trans(
"Month07"),
1122 8 => $outputlangs->trans(
"Month08"),
1123 9 => $outputlangs->trans(
"Month09"),
1124 10 => $outputlangs->trans(
"Month10"),
1125 11 => $outputlangs->trans(
"Month11"),
1126 12 => $outputlangs->trans(
"Month12")
1129 if (!empty($short)) {
1130 $montharray = array(
1131 1 => $outputlangs->trans(
"MonthShort01"),
1132 2 => $outputlangs->trans(
"MonthShort02"),
1133 3 => $outputlangs->trans(
"MonthShort03"),
1134 4 => $outputlangs->trans(
"MonthShort04"),
1135 5 => $outputlangs->trans(
"MonthShort05"),
1136 6 => $outputlangs->trans(
"MonthShort06"),
1137 7 => $outputlangs->trans(
"MonthShort07"),
1138 8 => $outputlangs->trans(
"MonthShort08"),
1139 9 => $outputlangs->trans(
"MonthShort09"),
1140 10 => $outputlangs->trans(
"MonthShort10"),
1141 11 => $outputlangs->trans(
"MonthShort11"),
1142 12 => $outputlangs->trans(
"MonthShort12")
1158 $nb_days = cal_days_in_month(CAL_GREGORIAN, $month, $year);
1160 for ($day = 1; $day < $nb_days; $day++) {
1162 $TWeek[$week_number] = $week_number;
1176 $TFirstDayOfWeek = array();
1177 foreach ($TWeek as $weekNb) {
1178 if (in_array(
'01', $TWeek) && in_array(
'52', $TWeek) && $weekNb ==
'01') {
1181 $TFirstDayOfWeek[$weekNb] = date(
'd', strtotime($year.
'W'.$weekNb));
1183 return $TFirstDayOfWeek;
1195 $TLastDayOfWeek = array();
1196 foreach ($TWeek as $weekNb) {
1197 $TLastDayOfWeek[$weekNb] = date(
'd', strtotime($year.
'W'.$weekNb.
'+6 days'));
1199 return $TLastDayOfWeek;
1212 $date =
new DateTime($year.
'-'.$month.
'-'.$day);
1213 $week = $date->format(
"W");
dol_get_prev_month($month, $year)
Return previous month.
dol_get_first_hour($date, $gm='tzserver')
Return GMT time for first hour of a given GMT date (it removes hours, min and second part)
dol_get_next_day($day, $month, $year)
Return next day.
dol_get_next_week($day, $week, $month, $year)
Return next week.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
getServerTimeZoneString()
Return server timezone string.
dol_get_last_hour($date, $gm='tzserver')
Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59...
getLastDayOfEachWeek($TWeek, $year)
Return array of last day of weeks.
getWeekNumbersOfMonth($month, $year)
Return array of week numbers.
getServerTimeZoneInt($refgmtdate='now')
Return server timezone int.
dol_get_first_day_week($day, $month, $year, $gm=false)
Return first day of week for a date.
getGMTEasterDatetime($year)
Return the easter day in GMT time.
convertDurationtoHour($duration_value, $duration_unit)
Convert duration to hour.
get_tz_array()
Return an array with timezone values.
dol_get_prev_day($day, $month, $year)
Return previous day.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
getFirstDayOfEachWeek($TWeek, $year)
Return array of first day of weeks.
dol_get_next_month($month, $year)
Return next month.
getWeekNumber($day, $month, $year)
Return week number.
num_between_day($timestampStart, $timestampEnd, $lastday=0)
Function to return number of days between two dates (date must be UTC date !) Example: 2012-01-01 201...
convertTime2Seconds($iHours=0, $iMinutes=0, $iSeconds=0)
Convert hours and minutes into seconds.
num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $country_code='')
Function to return number of working days (and text of units) between two dates (working days)
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
dol_get_prev_week($day, $week, $month, $year)
Return previous week.
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
monthArray($outputlangs, $short=0)
Return array of translated months or selected month.
num_public_holiday($timestampStart, $timestampEnd, $country_code='', $lastday=0, $includesaturday=-1, $includesunday=-1, $includefriday=-1, $includemonday=-1)
Return the number of non working days including Friday, Saturday and Sunday (or not) between 2 dates ...
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...