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 + ($duration_value);
133 if ($duration_unit ==
'i' || $duration_unit ==
'mn' || $duration_unit ==
'min') {
134 return $time + (60 * $duration_value);
136 if ($duration_unit ==
'h') {
137 return $time + (3600 * $duration_value);
139 if ($duration_unit ==
'w') {
140 return $time + (3600 * 24 * 7 * $duration_value);
145 if ($duration_value > 0) {
146 $deltastring .= abs($duration_value);
149 if ($duration_value < 0) {
150 $deltastring .= abs($duration_value);
153 if ($duration_unit ==
'd') {
156 if ($duration_unit ==
'm') {
159 if ($duration_unit ==
'y') {
163 $date =
new DateTime();
165 $date->setTimezone(
new DateTimeZone(
'UTC'));
167 $date->setTimestamp($time);
168 $interval =
new DateInterval($deltastring);
171 $date->sub($interval);
173 $date->add($interval);
176 if ($ruleforendofmonth == 1 && $duration_unit ==
'm') {
179 $timetotalmonths = (($timeyear * 12) + $timemonth);
181 $monthsexpected = ($timetotalmonths + $duration_value);
183 $newtime = $date->getTimestamp();
187 $newtimetotalmonths = (($newtimeyear * 12) + $newtimemonth);
189 if ($monthsexpected < $newtimetotalmonths) {
194 $datelim =
dol_mktime($newtimehours, $newtimemins, $newtimesecs, $newtimemonth, 1, $newtimeyear);
195 $datelim -= (3600 * 24);
197 $date->setTimestamp($datelim);
200 return $date->getTimestamp();
215 $iResult = ((int) $iHours * 3600) + ((int) $iMinutes * 60) + (int) $iSeconds;
246 if (empty($lengthOfDay)) {
247 $lengthOfDay = 86400;
249 if (empty($lengthOfWeek)) {
252 $nbHbyDay = $lengthOfDay / 3600;
254 if ($format ==
'all' || $format ==
'allwithouthour' || $format ==
'allhour' || $format ==
'allhourmin' || $format ==
'allhourminsec') {
255 if ((
int) $iSecond === 0) {
263 if ($iSecond >= $lengthOfDay) {
264 for ($i = $iSecond; $i >= $lengthOfDay; $i -= $lengthOfDay) {
266 $iSecond -= $lengthOfDay;
268 $dayTranslate = $langs->trans(
"Day");
269 if ($iSecond >= ($lengthOfDay * 2)) {
270 $dayTranslate = $langs->trans(
"Days");
274 if ($lengthOfWeek < 7) {
276 if ($sDay >= $lengthOfWeek) {
277 $sWeek = (int) (($sDay - $sDay % $lengthOfWeek) / $lengthOfWeek);
278 $sDay = $sDay % $lengthOfWeek;
279 $weekTranslate = $langs->trans(
"DurationWeek");
281 $weekTranslate = $langs->trans(
"DurationWeeks");
283 $sTime .= $sWeek.
' '.$weekTranslate.
' ';
288 $dayTranslate = $langs->trans(
"Day");
290 $dayTranslate = $langs->trans(
"Days");
292 $sTime .= $sDay.
' '.$langs->trans(
"d").
' ';
295 if ($format ==
'all') {
296 if ($iSecond || empty($sDay)) {
299 } elseif ($format ==
'allhourminsec') {
300 return sprintf(
"%02d", ($sWeek * $lengthOfWeek * $nbHbyDay + $sDay * $nbHbyDay + (
int) floor($iSecond / 3600))).
':'.sprintf(
"%02d", ((
int) floor(($iSecond % 3600) / 60))).
':'.sprintf(
"%02d", ((
int) ($iSecond % 60)));
301 } elseif ($format ==
'allhourmin') {
302 return sprintf(
"%02d", ($sWeek * $lengthOfWeek * $nbHbyDay + $sDay * $nbHbyDay + (
int) floor($iSecond / 3600))).
':'.sprintf(
"%02d", ((
int) floor(($iSecond % 3600) / 60)));
303 } elseif ($format ==
'allhour') {
304 return sprintf(
"%02d", ($sWeek * $lengthOfWeek * $nbHbyDay + $sDay * $nbHbyDay + (
int) floor($iSecond / 3600)));
306 } elseif ($format ==
'hour') {
308 } elseif ($format ==
'fullhour') {
309 if (!empty($iSecond)) {
310 $iSecond = $iSecond / 3600;
315 } elseif ($format ==
'min') {
317 } elseif ($format ==
'sec') {
319 } elseif ($format ==
'month') {
321 } elseif ($format ==
'year') {
338 if ($duration_unit ==
's') {
339 $result = $duration_value / 3600;
341 if ($duration_unit ==
'i' || $duration_unit ==
'mn' || $duration_unit ==
'min') {
342 $result = $duration_value / 60;
344 if ($duration_unit ==
'h') {
345 $result = $duration_value;
347 if ($duration_unit ==
'd') {
348 $result = $duration_value * 24;
350 if ($duration_unit ==
'w') {
351 $result = $duration_value * 24 * 7;
353 if ($duration_unit ==
'm') {
354 $result = $duration_value * 730.484;
356 if ($duration_unit ==
'y') {
357 $result = $duration_value * 365 * 24;
378function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand = 0, $gm =
false)
383 $day_date = intval($day_date);
384 $month_date = intval($month_date);
385 $year_date = intval($year_date);
387 if ($month_date > 0) {
388 if ($month_date > 12) {
391 if ($year_date > 0 && empty($day_date)) {
392 $sqldate .= ($excludefirstand ?
"" :
" AND ").$datefield.
" BETWEEN '".$db->idate(
dol_get_first_day($year_date, $month_date, $gm));
393 $sqldate .=
"' AND '".$db->idate(
dol_get_last_day($year_date, $month_date, $gm)).
"'";
394 } elseif ($year_date > 0 && !empty($day_date)) {
395 $sqldate .= ($excludefirstand ?
"" :
" AND ").$datefield.
" BETWEEN '".$db->idate(
dol_mktime(0, 0, 0, $month_date, $day_date, $year_date, $gm));
396 $sqldate .=
"' AND '".$db->idate(
dol_mktime(23, 59, 59, $month_date, $day_date, $year_date, $gm)).
"'";
399 $sqldate .= ($excludefirstand ?
"" :
" AND ").
" date_format( ".$datefield.
", '%c') = '".$db->escape($month_date).
"'";
401 } elseif ($year_date > 0) {
402 $sqldate .= ($excludefirstand ?
"" :
" AND ").$datefield.
" BETWEEN '".$db->idate(
dol_get_first_day($year_date, 1, $gm));
403 $sqldate .=
"' AND '".$db->idate(
dol_get_last_day($year_date, 12, $gm)).
"'";
431 if (preg_match(
'/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $string, $reg)) {
432 dol_syslog(
"dol_stringtotime call to function with deprecated parameter format", LOG_WARNING);
435 $sday = (int) $reg[1];
436 $smonth = (int) $reg[2];
437 $syear = (int) $reg[3];
438 $shour = (int) $reg[4];
439 $smin = (int) $reg[5];
440 $ssec = (int) $reg[6];
444 if ($syear >= 50 && $syear < 100) {
447 $string = sprintf(
"%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec);
448 } 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)
449 || preg_match(
'/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/i', $string, $reg)
450 || 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)
452 $syear = (int) $reg[1];
453 $smonth = (int) $reg[2];
454 $sday = (int) $reg[3];
455 $shour = (int) $reg[4];
456 $smin = (int) $reg[5];
457 $ssec = (int) $reg[6];
458 $string = sprintf(
"%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec);
461 $string = preg_replace(
'/([^0-9])/i',
'', $string);
462 $tmp = $string.
'000000';
466 } elseif (empty($gm) || $gm ===
'tzserver') {
470 $date =
dol_mktime(substr($tmp, 8, 2), substr($tmp, 10, 2), substr($tmp, 12, 2), substr($tmp, 4, 2), substr($tmp, 6, 2), substr($tmp, 0, 4), $gm);
485 $time =
dol_mktime(12, 0, 0, $month, $day, $year, 1, 0);
486 $time -= 24 * 60 * 60;
488 return array(
'year' => $tmparray[
'year'],
'month' => $tmparray[
'mon'],
'day' => $tmparray[
'mday']);
501 $time =
dol_mktime(12, 0, 0, $month, $day, $year, 1, 0);
502 $time += 24 * 60 * 60;
504 return array(
'year' => $tmparray[
'year'],
'month' => $tmparray[
'mon'],
'day' => $tmparray[
'mday']);
518 $prev_year = $year - 1;
520 $prev_month = $month - 1;
523 return array(
'year' => $prev_year,
'month' => $prev_month);
537 $next_year = $year + 1;
539 $next_month = $month + 1;
542 return array(
'year' => $next_year,
'month' => $next_month);
558 $time =
dol_mktime(12, 0, 0, $month, $tmparray[
'first_day'], $year, 1, 0);
559 $time -= 24 * 60 * 60 * 7;
561 return array(
'year' => $tmparray[
'year'],
'month' => $tmparray[
'mon'],
'day' => $tmparray[
'mday']);
577 $time =
dol_mktime(12, 0, 0, $tmparray[
'first_month'], $tmparray[
'first_day'], $tmparray[
'first_year'], 1, 0);
578 $time += 24 * 60 * 60 * 7;
581 return array(
'year' => $tmparray[
'year'],
'month' => $tmparray[
'mon'],
'day' => $tmparray[
'mday']);
600 return dol_mktime(0, 0, 0, $month, 1, $year, $gm);
627 $datelim =
dol_mktime(23, 59, 59, $month, 1, $year, $gm);
628 $datelim -= (3600 * 24);
643 $tmparray =
dol_getdate($date,
false, ($gm ==
'gmt' ?
'gmt' :
''));
644 return dol_mktime(23, 59, 59, $tmparray[
'mon'], $tmparray[
'mday'], $tmparray[
'year'], $gm);
657 $tmparray =
dol_getdate($date,
false, ($gm ==
'gmt' ?
'gmt' :
''));
658 return dol_mktime(0, 0, 0, $tmparray[
'mon'], $tmparray[
'mday'], $tmparray[
'year'], $gm);
675 $date =
dol_mktime(0, 0, 0, $month, $day, $year, $gm);
678 $start_week = (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1);
683 $days = $start_week - $tmparray[
'wday'];
688 $seconds = $days * 24 * 60 * 60;
692 $tmpdaytms = (int) date((
string) $tmparray[
'0']) - $seconds;
693 $tmpday = idate(
"d", $tmpdaytms);
696 if ($tmpday > $day) {
697 $prev_month = $month - 1;
700 if ($prev_month == 0) {
702 $prev_year = $year - 1;
705 $prev_month = $month;
708 $tmpmonth = $prev_month;
709 $tmpyear = $prev_year;
712 $tmptime =
dol_mktime(12, 0, 0, $month, $tmpday, $year, 1, 0);
713 $tmptime -= 24 * 60 * 60 * 7;
715 $prev_day = $tmparray[
'mday'];
718 if ($prev_day > $tmpday) {
719 $prev_month = $month - 1;
722 if ($prev_month == 0) {
724 $prev_year = $year - 1;
728 $week = date(
"W",
dol_mktime(0, 0, 0, $tmpmonth, $tmpday, $tmpyear, $gm));
730 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);
742 $base =
new DateTime(
"$year-03-21",
new DateTimeZone(
"UTC"));
743 $days = easter_days($year);
744 $tmp = $base->add(
new DateInterval(
"P{$days}D"));
745 return $tmp->getTimestamp();
764function num_public_holiday($timestampStart, $timestampEnd, $country_code =
'', $lastday = 0, $includesaturday = -1, $includesunday = -1, $includefriday = -1, $includemonday = -1)
766 global $conf, $db, $mysoc;
771 if (($timestampEnd - $timestampStart) % 86400 != 0) {
772 return 'Error Dates must use same hours and must be GMT dates';
775 if (empty($country_code)) {
776 $country_code = $mysoc->country_code;
778 if ($includemonday < 0) {
779 $includemonday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY', 0);
781 if ($includefriday < 0) {
782 $includefriday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY', 0);
784 if ($includesaturday < 0) {
785 $includesaturday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY', 1);
787 if ($includesunday < 0) {
788 $includesunday =
getDolGlobalInt(
'MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY', 1);
791 $country_id =
dol_getIdFromCode($db, $country_code,
'c_country',
'code',
'rowid');
793 if (empty($conf->cache[
'arrayOfActivePublicHolidays_'.$country_id])) {
795 $tmpArrayOfPublicHolidays = array();
796 $sql =
"SELECT id, code, entity, fk_country, dayrule, year, month, day, active";
797 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_hrm_public_holiday";
798 $sql .=
" WHERE active = 1 and fk_country IN (0".($country_id > 0 ?
", ".$country_id : 0).
")";
799 $sql .=
" AND entity IN (0," .getEntity(
'holiday') .
")";
801 $resql = $db->query($sql);
803 $num_rows = $db->num_rows($resql);
805 while ($i < $num_rows) {
806 $obj = $db->fetch_object($resql);
807 $tmpArrayOfPublicHolidays[$obj->id] = array(
'dayrule' => $obj->dayrule,
'year' => $obj->year,
'month' => $obj->month,
'day' => $obj->day);
812 return 'Error sql '.$db->lasterror();
816 $conf->cache[
'arrayOfActivePublicHolidays_'.$country_id] = $tmpArrayOfPublicHolidays;
819 $arrayOfPublicHolidays = $conf->cache[
'arrayOfActivePublicHolidays_'.$country_id];
822 while ((($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd))
825 $specialdayrule = array();
827 $jour = (int) gmdate(
"d", $timestampStart);
828 $mois = (int) gmdate(
"m", $timestampStart);
829 $annee = (int) gmdate(
"Y", $timestampStart);
832 foreach ($arrayOfPublicHolidays as $entrypublicholiday) {
833 if (!empty($entrypublicholiday[
'dayrule']) && $entrypublicholiday[
'dayrule'] !=
'date') {
834 $specialdayrule[$entrypublicholiday[
'dayrule']] = $entrypublicholiday[
'dayrule'];
837 if (!empty($entrypublicholiday[
'year']) && $entrypublicholiday[
'year'] != $annee) {
840 if ($entrypublicholiday[
'month'] != $mois) {
843 if ($entrypublicholiday[
'day'] != $jour) {
859 if (in_array(
'easter', $specialdayrule)) {
862 $jour_paques = gmdate(
"d", $date_paques);
863 $mois_paques = gmdate(
"m", $date_paques);
864 if ($jour_paques == $jour && $mois_paques == $mois) {
870 if (in_array(
'eastermonday', $specialdayrule)) {
874 $date_lundi_paques = $date_paques + (3600 * 24);
875 $jour_lundi_paques = gmdate(
"d", $date_lundi_paques);
876 $mois_lundi_paques = gmdate(
"m", $date_lundi_paques);
877 if ($jour_lundi_paques == $jour && $mois_lundi_paques == $mois) {
885 if (in_array(
'goodfriday', $specialdayrule)) {
890 $date_good_friday = $easter - (2 * 3600 * 24);
891 $dom_good_friday = gmdate(
"d", $date_good_friday);
892 $month_good_friday = gmdate(
"m", $date_good_friday);
894 if ($dom_good_friday == $jour && $month_good_friday == $mois) {
899 if (in_array(
'ascension', $specialdayrule)) {
902 $date_ascension = $date_paques + (3600 * 24 * 39);
903 $jour_ascension = gmdate(
"d", $date_ascension);
904 $mois_ascension = gmdate(
"m", $date_ascension);
905 if ($jour_ascension == $jour && $mois_ascension == $mois) {
911 if (in_array(
'pentecost', $specialdayrule)) {
914 $date_pentecote = $date_paques + (3600 * 24 * 49);
915 $jour_pentecote = gmdate(
"d", $date_pentecote);
916 $mois_pentecote = gmdate(
"m", $date_pentecote);
917 if ($jour_pentecote == $jour && $mois_pentecote == $mois) {
922 if (in_array(
'pentecotemonday', $specialdayrule)) {
925 $date_pentecote = $date_paques + (3600 * 24 * 50);
926 $jour_pentecote = gmdate(
"d", $date_pentecote);
927 $mois_pentecote = gmdate(
"m", $date_pentecote);
928 if ($jour_pentecote == $jour && $mois_pentecote == $mois) {
934 if (in_array(
'viernessanto', $specialdayrule)) {
937 $date_viernes = $date_paques - (3600 * 24 * 2);
938 $jour_viernes = gmdate(
"d", $date_viernes);
939 $mois_viernes = gmdate(
"m", $date_viernes);
940 if ($jour_viernes == $jour && $mois_viernes == $mois) {
946 if (in_array(
'fronleichnam', $specialdayrule)) {
949 $date_fronleichnam = $date_paques + (3600 * 24 * 60);
950 $jour_fronleichnam = gmdate(
"d", $date_fronleichnam);
951 $mois_fronleichnam = gmdate(
"m", $date_fronleichnam);
952 if ($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) {
958 if (in_array(
'genevafast', $specialdayrule)) {
960 $date_1sunsept = strtotime(
'next thursday', strtotime(
'next sunday', mktime(0, 0, 0, 9, 1, $annee)));
961 $jour_1sunsept = date(
"d", $date_1sunsept);
962 $mois_1sunsept = date(
"m", $date_1sunsept);
963 if ($jour_1sunsept == $jour && $mois_1sunsept == $mois) {
973 if ($includefriday || $includesaturday || $includesunday) {
974 $jour_julien = unixtojd($timestampStart);
975 $jour_semaine = jddayofweek($jour_julien, 0);
976 if ($includefriday) {
977 if ($jour_semaine == 5) {
981 if ($includesaturday) {
982 if ($jour_semaine == 6) {
986 if ($includesunday) {
987 if ($jour_semaine == 0) {
1023 if ($timestampStart < $timestampEnd) {
1024 if ($lastday == 1) {
1029 $nbjours = (int) floor(($timestampEnd - $timestampStart) / (60 * 60 * 24)) + 1 - $bit;
1049function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0, $halfday = 0, $country_code =
'')
1051 global $langs, $mysoc;
1053 if (empty($country_code)) {
1054 $country_code = $mysoc->country_code;
1057 dol_syslog(
'num_open_day timestampStart='.$timestampStart.
' timestampEnd='.$timestampEnd.
' bit='.$lastday.
' country_code='.$country_code);
1060 if (!is_int($timestampStart) && !is_float($timestampStart)) {
1061 return 'ErrorBadParameter_num_open_day';
1063 if (!is_int($timestampEnd) && !is_float($timestampEnd)) {
1064 return 'ErrorBadParameter_num_open_day';
1068 if ($timestampStart < $timestampEnd) {
1071 $numholidays =
num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday);
1072 $nbOpenDay = ($numdays - $numholidays);
1073 if ($inhour == 1 && $nbOpenDay <= 3) {
1074 $nbOpenDay = ($nbOpenDay * 24);
1076 return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
1077 } elseif ($timestampStart == $timestampEnd) {
1080 $numholidays =
num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday);
1081 if ($numholidays == 1) {
1086 $nbOpenDay = $lastday;
1089 $nbOpenDay = ($nbOpenDay * 24);
1091 return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
1093 return $langs->trans(
"Error");
1109 $montharray = array(
1110 1 => $outputlangs->trans(
"Month01"),
1111 2 => $outputlangs->trans(
"Month02"),
1112 3 => $outputlangs->trans(
"Month03"),
1113 4 => $outputlangs->trans(
"Month04"),
1114 5 => $outputlangs->trans(
"Month05"),
1115 6 => $outputlangs->trans(
"Month06"),
1116 7 => $outputlangs->trans(
"Month07"),
1117 8 => $outputlangs->trans(
"Month08"),
1118 9 => $outputlangs->trans(
"Month09"),
1119 10 => $outputlangs->trans(
"Month10"),
1120 11 => $outputlangs->trans(
"Month11"),
1121 12 => $outputlangs->trans(
"Month12")
1124 if (!empty($short)) {
1125 $montharray = array(
1126 1 => $outputlangs->trans(
"MonthShort01"),
1127 2 => $outputlangs->trans(
"MonthShort02"),
1128 3 => $outputlangs->trans(
"MonthShort03"),
1129 4 => $outputlangs->trans(
"MonthShort04"),
1130 5 => $outputlangs->trans(
"MonthShort05"),
1131 6 => $outputlangs->trans(
"MonthShort06"),
1132 7 => $outputlangs->trans(
"MonthShort07"),
1133 8 => $outputlangs->trans(
"MonthShort08"),
1134 9 => $outputlangs->trans(
"MonthShort09"),
1135 10 => $outputlangs->trans(
"MonthShort10"),
1136 11 => $outputlangs->trans(
"MonthShort11"),
1137 12 => $outputlangs->trans(
"MonthShort12")
1153 $nb_days = cal_days_in_month(CAL_GREGORIAN, $month, $year);
1155 for ($day = 1; $day < $nb_days; $day++) {
1157 $TWeek[$week_number] = $week_number;
1171 $TFirstDayOfWeek = array();
1172 foreach ($TWeek as $weekNb) {
1173 if (in_array(
'01', $TWeek) && in_array(
'52', $TWeek) && $weekNb ==
'01') {
1176 $TFirstDayOfWeek[$weekNb] = date(
'd', strtotime($year.
'W'.$weekNb));
1178 return $TFirstDayOfWeek;
1190 $TLastDayOfWeek = array();
1191 foreach ($TWeek as $weekNb) {
1192 $TLastDayOfWeek[$weekNb] = date(
'd', strtotime($year.
'W'.$weekNb.
'+6 days'));
1194 return $TLastDayOfWeek;
1207 $date =
new DateTime($year.
'-'.$month.
'-'.$day);
1208 $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 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.