$f) { $i = strtolower($i); if ( ($f == 1) && ($current_user->holiday[$i] == 1) ) { error_reporting(E_ALL); include "localization/holiday_". $i .".pinc"; error_reporting($tutos['error_reporting']); } } return; } /* * Read and fill the namedays array */ function ReadNamedayInfo() { global $current_user,$tutos; $tutos['nd'] = array(); @reset($tutos[nameday]); while( list ($i,$f) = @each ($tutos[nameday])) { $i = strtolower($i); if ( ($f == 1) && ($current_user->nameday[$i] == 1) ) { include "localization/namedays_". $i .".p3"; } } return; } /* * Check if the given date is a holiday in one of the enabled holidy sets * if user wants to show namedays, then do it * t = Date in timestamp format */ function GetExtendedDayInfo($t) { global $tutos, $current_user; $desc = ""; $mark = 0; $today = getdate($t); $wd = Date("D",$t); $month = Date("m",$t); /* Yearly Days */ $day = Date("d-m",$t); # We need the easter date for some calculation $J = Date("Y",$t); $a = $J % 19; $b = $J % 4; $c = $J % 7; $d = (19 * $a + 24) % 30; $e = (2 * $b + 4 * $c + 6 * $d + 5) % 7; $OT = 22 + $d + $e; $OM = 3; if ( $OT > 31 ) { $OT = $d + $e - 9; $OM = 4; } if ( ($OT == 26) && ($OM == 4) ) { $OT = 19; } if ( ($OT == 25) && ($OM == 4) && ($d == 28) && ($e == 6) && ($a > 10) ) { $OT = 18; } $br = "
"; # Walk over namedays $nd = Date("j",$t); $nm = Date("n",$t); for ($ii = 0 ; $ii < count($tutos['nd']); $ii++) { if ( isset($tutos['nd'][$ii][$nm][$nd]) ) { $desc .= $tutos['nd'][$ii][$nm][$nd].$br; } } # Walk over claendars for ($ii = 0 ; $ii < count($tutos[cal]); $ii++) { $cnt = count($tutos[cal][$ii]); for ($ij = 0 ; $ij < $cnt; $ij++) { if ( ! isset($tutos[cal][$ii][$ij][type])) { $tutos[cal][$ii][$ij][type] = 1; } /* Yearly Days */ if ($tutos[cal][$ii][$ij][Date] == $day) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; continue; } /* Holidays defined by Weekday */ if ( $wd == "Mon" ) { /* Date calculation for Dutch carnaval monday by Robert Brouwer */ if ($tutos[cal][$ii][$ij][Date] == "CARNAVALMON") { $tp = mktime (0,0,0,$OM,$OT,$J); $tp -= (7*7) * 86400; $tp += 2*86400; $pday = Date("d-m",$tp); if ( $day == $pday ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } } elseif ($tutos[cal][$ii][$ij][Date] == "EASTERMONDAY") { $tp = mktime (0,0,0,$OM,$OT,$J); $tp += 86400; $pday = Date("d-m",$tp); if ( $day == $pday ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } } elseif ($tutos[cal][$ii][$ij][Date] == "WHITMONDAY") { $tp = mktime (0,0,0,$OM,$OT,$J); $tp += 7 * 7 * 86400; $tp += 86400; $pday = Date("d-m",$tp); if ( $day == $pday ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } } elseif (($tutos[cal][$ii][$ij][Date] == "MARTINLUTHERKING") && ($month == "01") && ($today['mday'] == nthday(3, $today['wday'], $today['mon'], $today['year'])) ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } elseif (($tutos[cal][$ii][$ij][Date] == "WASHINGTON") && ($month == "02") && ($today['mday'] == nthday(3, $today['wday'], $today['mon'], $today['year'])) ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } elseif (($tutos[cal][$ii][$ij][Date] == "MEMORIALDAY") && ($month == "05") && ($today['mday'] == nthday(-1, $today['wday'], $today['mon'], $today['year'])) ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } elseif (($tutos[cal][$ii][$ij][Date] == "LABORDAY") && ($month == "09") && ($today['mday'] == nthday(1, 1, $today['mon'], $today['year'])) ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } elseif (($tutos[cal][$ii][$ij][Date] == "COLUMBUSDAY") && ($month == "10") && ($today['mday'] == nthday(2, 1, $today['mon'], $today['year'])) ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } } elseif ( $wd == "Tue" ) { /* Date calculation for Dutch 'Prinsjesdag' by Robert Brouwer */ if ($tutos[cal][$ii][$ij][Date] == "PRINSDAY" && ($month == "09") && ($today['mday'] == nthday(3, $today['wday'], $today['mon'], $today['year']))) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } /* Date calculation for Dutch carnaval tuesday by Robert Brouwer */ elseif ($tutos[cal][$ii][$ij][Date] == "CARNAVALTUE") { $tp = mktime (0,0,0,$OM,$OT,$J); $tp -= (7*7) * 86400; $tp += 3* 86400; $pday = Date("d-m",$tp); if ( $day == $pday ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } } } elseif ( $wd == "Wed" ) { /* Date calculation for Dutch carnaval wednesday by Robert Brouwer */ if ($tutos[cal][$ii][$ij][Date] == "CARNAVALWED") { $tp = mktime (0,0,0,$OM,$OT,$J); $tp -= (7*7) * 86400; $tp += 4 * 86400; $pday = Date("d-m",$tp); if ( $day == $pday ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } } } elseif ( $wd == "Thu" ) { # Christ Himmelfahrt if ($tutos[cal][$ii][$ij][Date] == "ASCENSIONDAY") { $tp = mktime (0,0,0,$OM,$OT,$J); $tp += (5*7 +4) * 86400; $pday = Date("d-m",$tp); if ( $day == $pday ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } } elseif ($tutos[cal][$ii][$ij][Date] == "FRONLEICHNAM") { $tp = mktime (0,0,0,$OM,$OT,$J); $tp += (8*7 +4) * 86400; $pday = Date("d-m",$tp); if ( $day == $pday ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } } elseif (($tutos[cal][$ii][$ij][Date] == "THANKSGIVING") && ($month == "11") && ($today['mday'] == nthday(4, $today['wday'], $today['mon'], $today['year'])) ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } } elseif ( $wd == "Fri" ) { if ($tutos[cal][$ii][$ij][Date] == "GOODFRIDAY") { $tp = mktime (0,0,0,$OM,$OT,$J); $tp -= 2 * 86400; $pday = Date("d-m",$tp); if ( $day == $pday ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } } } elseif ( $wd == "Sun" ) { if ($tutos[cal][$ii][$ij][Date] == "EASTERSUNDAY") { if ( $day == sprintf("%02d-%02d",$OT,$OM) ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } /* Date calculation for Dutch 'Moederdag' (Mothersday') by Robert Brouwer */ } elseif ($tutos[cal][$ii][$ij][Date] == "MOTHERDAY" && ($month == "5") && ($today['mday'] == nthday(2, $today['wday'], $today['mon'], $today['year'])) ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; /* Date calculation for Dutch 'Vaderdag' (Fathersday') by Robert Brouwer */ } elseif ($tutos[cal][$ii][$ij][Date] == "FATHERDAY" && ($month == "6") && ($today['mday'] == nthday(3, $today['wday'], $today['mon'], $today['year'])) ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } elseif ($tutos[cal][$ii][$ij][Date] == "WHITSUNDAY") { $tp = mktime (0,0,0,$OM,$OT,$J); $tp += 7 * 7 * 86400; $pday = Date("d-m",$tp); if ( $day == $pday ) { $desc .= $tutos[cal][$ii][$ij][Desc].$br; $mark += $tutos[cal][$ii][$ij][type]; } } } } } if ( $desc == "" ) { return array(color => "appday"); } else { if ( $mark > 0 ) { return array(color => "holiday", Desc => "".substr($desc,0,-1*strlen($br)).""); } else { return array(color => "appday", Desc => "".substr($desc,0,-1*strlen($br)).""); } } } /* --------------------------------------------------------------------------- * Evaluate the Color for day t * t = Date in timestamp format * */ function GetDaysInfo($t) { $dinfo = GetExtendedDayInfo($t); if (!empty($dinfo[Desc])) { $dinfo[popinfo] = ''; $dinfo[popinfo] .= ''; $dinfo[popinfo] .= '
'; $dinfo[popinfo] .= eregi_replace("'","\'",$dinfo[Desc]); $dinfo[popinfo] .= '
'; } # Today if ( Date("d.m.Y",$t) == Date("d.m.Y") ) { $dinfo[color] = "today"; return $dinfo; } $wd = Date("D",$t); $month = Date("m",$t); # Change here for islamic/arabic week scheme # Sundays are free if ( $wd == "Sun" ) { $dinfo[color] = "holiday"; return $dinfo; } # Saturdays are something special if ( $wd == "Sat" ) { $dinfo[color] = "freeday"; return $dinfo; } return $dinfo; }; /** * Intern Representation of Date and Time * * @package BASE * @module DateTime */ class DateTime { /** * str is whatever a database gives us * -1 = now */ function DateTime( $str = "-1" ) { global $current_user; $this->notime = 0; $this->orig = $str; if ( $str == -1 ) { $this->day = Date("j"); $this->month = Date("n"); $this->year = Date("Y"); $this->hour = Date("H"); $this->min = Date("i"); $this->sec = Date("s"); $this->ts = time(); $this->ts_def = $this->ts; //if ( isset($current_user) && ($current_user->offset != 0) ) { // $this->ts_def -= $current_user->offset; //} $this->tz = Date("T"); $this->offset = Date("Z"); $this->format = -1; } else { if (($str == "0") || ($str == "")) { $this->setNoTime(); } else { $this->setDateTime($str); } } } /** * set datetime to nothing */ function setNoTime() { $this->notime = 1; $this->day = -1; $this->month = -1; $this->year = -1; $this->hour = -1; $this->min = -1; $this->sec = 0; $this->ts = -1; } /** * set datetime for a timestamp * ts is assumed in current_users TZ */ function setDateTimeTS($ts,$notz = 0) { global $current_user; if ( $ts != -1 ) { $this->notime = 0; } $this->day = (integer)Date("d",$ts); $this->month = (integer)Date("m",$ts); $this->year = (integer)Date("Y",$ts); $this->hour = (integer)Date("H",$ts); $this->min = (integer)Date("i",$ts); $this->sec = (integer)Date("s",$ts); $this->ts = mktime($this->hour,$this->min,$this->sec,$this->month,$this->day,$this->year); $this->orig = "TS"; $this->format = "TS"; $this->ts_def = $ts; if ( ($current_user->offset != 0) && ($notz == 0) ) { $this->ts_def -= $current_user->offset; } } /** * set DateTime by variables (incoming variables are in the users TZ) * used via form */ function setDateTimeF($str,$notz = 0) { global $current_user; $this->orig = "fields $str"; $this->format = "fields"; if ( count($_GET) ) { foreach ($_GET as $i => $f) { $x[$i] = $f; } } if ( count($_POST) ) { foreach ($_POST as $i => $f) { $x[$i] = $f; } } $v = sprintf("%s_d",$str); if ( isset($x[$v]) ) { $this->day = (integer)$x[$v]; } $v = sprintf("%s_m",$str); if ( isset($x[$v]) ) { $this->month = (integer)$x[$v]; } $v = sprintf("%s_y",$str); if ( isset($x[$v]) ) { $this->year = (integer)$x[$v]; } $v = sprintf("%s_H",$str); if ( isset($x[$v]) ) { $this->hour = (integer)$x[$v]; } else { $this->hour = 0; } $v = sprintf("%s_M",$str); if ( isset($x[$v]) ) { $this->min = (integer)$x[$v]; } else { $this->min = 0; } $this->sec = 0; $this->ts = mktime($this->hour,$this->min,$this->sec,$this->month,$this->day,$this->year); if ( ($this->day < 1) || ($this->month < 1) || ($this->year < 1) ) { $this->setNoTime(); } else { $this->notime = 0; } if ( $this->checkDMY() == false) { $this->setNoTime(); } # settype($this->day,"integer"); # settype($this->month,"integer"); # settype($this->year,"integer"); $this->ts_def = $this->ts; if ( ($current_user->offset != 0) && ($notz == 0) ) { $this->ts_def -= $current_user->offset; } } /** * Checks if DMY fields are valid */ function checkDMY($notime_allowed = false) { if ( $this->notime == 1 ) { return $notime_allowed; } if ( $this->day < 1 ) { return 0;} if ( $this->day > 31 ) { return 0;} if ( $this->month < 1 ) { return 0;} if ( $this->month > 12 ) { return 0;} if ( $this->hour < 0 ) { return 0;} if ( $this->hour > 23 ) { return 0;} if ( $this->min < 0 ) { return 0;} if ( $this->min > 59 ) { return 0;} if ( (Date("n-j",$this->ts) != $this->month ."-". $this->day) && ($this->ts >= 0) ) { return false; } return true; } /** * * On MySQL the given time is in tutos[defaultTZ] we have to fix the offset * On Postgres it is in the current users TZ * */ function setDateTime($str,$notz = 0) { global $current_user , $tutos; if ( ! isset ($str) ) return; if ( empty ($str) ) return; $this->format = 0; $this->orig = $str; $this->notime = 0; $regs = array(); if ( $str == "epoch" ) { $this->setNoTime(); return; }; if (($str == "0") || ($str == "") || ($str== "--------") || ($str == "------------") ) { $this->setNoTime(); return; }; # check the registered formats foreach($tutos['dateformat'] as $f) { @$f($this,$str); if ($this->format != 0) { # echo $str." ". $f ."
"; break; } } # if ($this->format == 0) { # echo $str." X
"; # } if ($this->format != 0) { } else if ( ereg( "^([0-9]{1,2}).([0-9]{1,2}).([0-9]{4}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\.([0-9]+) ([a-z]*)$", $str, $regs ) ) { # Init via DB 06.02.2001 17:39:32.00 CET Postgres 7.1 $this->month = (integer)$regs[1]; $this->day = (integer)$regs[2]; $this->year = (integer)$regs[3]; $this->hour = (integer)$regs[4]; $this->min = (integer)$regs[5]; $this->sec = (integer)$regs[6]; $this->format = 10; } else if ( ereg( "^([0-1][0-9])([0-3][0-9])([0-9]{4})$", $str, $regs ) ) { # Init via DB MMDDYYYY $this->month = (integer)$regs[1]; $this->day = (integer)$regs[2]; $this->year = (integer)$regs[3]; $this->hour = 0; $this->min = 0; $this->sec = 0; $this->format = 4; } else if ( ereg( "^([0-9]{4})-?([0-1][0-9])-?([0-3][0-9]) ?([0-2][0-9]):?([0-5][0-9]):?([0-5][0-9])$", $str, $regs ) ) { # Init via YYYYMMDDHHMMSS or YYYY-MM-DD HH:MM:SS used in calendar $this->year = (integer)$regs[1]; $this->month = (integer)$regs[2]; $this->day = (integer)$regs[3]; $this->hour = (integer)$regs[4]; $this->min = (integer)$regs[5]; $this->sec = (integer)$regs[6]; $this->format = 5; } else if ( ereg( "([0-9]{4})([0-1][0-9])([0-3][0-9])([0-2][0-9])([0-5][0-9])", $str, $regs ) ) { # Init via YYYYMMDDHHMM $this->year = (integer)$regs[1]; $this->month = (integer)$regs[2]; $this->day = (integer)$regs[3]; $this->hour = (integer)$regs[4]; $this->min = (integer)$regs[5]; $this->sec = 0; $this->format = 6; } else if ( ereg( "^([0-9]{4})([0-1][0-9])([0-3][0-9])$", $str, $regs ) ) { # Init via YYYYMMDD used in calendar $this->year = (integer)$regs[1]; $this->month = (integer)$regs[2]; $this->day = (integer)$regs[3]; $this->hour = 0; $this->min = 0; $this->sec = 0; $this->format = 7; } else if ( ereg( "^([0-1][0-9])-([0-3][0-9])-([0-9]{4})$", $str, $regs ) ) { # Init via MM-DD-YYYY $this->month = (integer)$regs[1]; $this->day = (integer)$regs[2]; $this->year = (integer)$regs[3]; $this->hour = 0; $this->min = 0; $this->sec = 0; $this->format = 8; } else { echo "
DT: Unknown DateTimeFormat ". $str ." fix it in Date.pinc or register a DB specific format
"; return; } $this->ts = mktime($this->hour,$this->min,$this->sec,$this->month,$this->day,$this->year); $this->ts_def = $this->ts; if ( ($current_user->offset != 0) && ($notz == 0) ) { $this->ts += $current_user->offset; // Set the fields according to offset $this->setDateTimeTS($this->ts); } } /** * part of a form used to enter a day */ function EnterDay($name,$none = 0) { $x = sprintf("%s_d",$name ); echo "\n"; } /** * parts of a form used to enter a month */ function EnterMonth($name,$none = 0) { $x = sprintf("%s_m",$name ); echo "\n"; } /** * parts of a form used to enter a year * future_only = try to allow only date in the future (i.e. years) */ function EnterYear($name,$none = 0,$future_only = false) { $x = sprintf("%s_y",$name ); echo "\n"; } function ShowMinical($name, $none = 0) { global $tutos,$callink; if ( !isset($_SERVER['HTTP_USER_AGENT']) || ereg("Lynx",$_SERVER['HTTP_USER_AGENT']) || ereg("w3m",$_SERVER['HTTP_USER_AGENT']) ) { # Do nothing } else { echo "\n"; echo "minical\n"; echo "\n"; } } /** * ask for date * none = 0 (no date not allowed) * none = 1 (allowed to enter nothing) */ function EnterDate($name,$none = 0,$future_only = false) { global $tutos; if ( $tutos['df'] == 1 ) { $this->EnterMonth($name,$none); } else { $this->EnterDay($name,$none); } echo ". "; if ( $tutos['df'] == 1 ) { $this->EnterDay($name,$none); } else { $this->EnterMonth($name,$none); } echo ". "; $this->EnterYear($name,$none,$future_only); $this->ShowMinical($name, $none); } /** * enter a time into a form */ function EnterTime($name) { $h = sprintf("%s_H",$name ); $m = sprintf("%s_M",$name ); echo "hour) ."\" />\n"; echo " : "; echo "min) ."\" />\n"; } /** * ask for date * none = 0 (no date not allowed) * none = 1 (allowed to enter nothing) * future_only = try to allow only date in the future (i.e. years) */ function EnterDateTime($name,$none = 0,$future_only = false) { global $tutos; if ( $tutos['df'] == 1 ) { $this->EnterMonth($name,$none); } else { $this->EnterDay($name,$none); } echo ". "; if ( $tutos['df'] == 1 ) { $this->EnterDay($name,$none); } else { $this->EnterMonth($name,$none); } echo ". "; $this->EnterYear($name,$none,$future_only); $h = sprintf("%s_H",$name ); $m = sprintf("%s_M",$name ); echo "hour == -1 ? "--":$this->hour) ."\" />\n"; echo " : "; echo "min == -1 ? "--":$this->min) ."\" />\n"; $this->ShowMinical($name, $none); } /* --------------------------------------------------------------------------- */ function getDateTimeShort() { global $lang; if ( $this->notime == 1) { return sprintf ($lang['DateTimeSFormat'],"--","--","--","--"); } return strftime($lang['DateTimeSStr'],$this->ts); } /* --------------------------------------------------------------------------- */ function getDateTime() { global $lang; if ( $this->notime == 1) { return sprintf ($lang['DateTimeFormat'],"--","--","----","--","--"," "); } # return strftime($lang['DateTimeStr'],$this->ts); return Date($lang['DateTimePHP'],$this->ts); } /* --------------------------------------------------------------------------- */ function getTime() { global $lang; if ( $this->notime == 1) { return sprintf ($lang['TimeFormat'],"--","--"); } return strftime($lang['TimeFormatStr'],$this->ts); } /* --------------------------------------------------------------------------- */ function getDate() { global $lang,$tutos; if ( $this->notime == 1) { return sprintf ($lang['DateFormat'],"--","--","----"); } return sprintf ($lang['DateFormat'],$this->day,$this->month,$this->year); } /* --------------------------------------------------------------------------- */ function getDateShort() { global $lang,$tutos; if ( $this->notime == 1) { return sprintf ($lang['DateShortFormat'],"--","--"); } return sprintf ($lang['DateShortFormat'],$this->day,$this->month); } /* --------------------------------------------------------------------------- */ function getYYYYMMDD() { if ( $this->notime == 1) { return "--------"; } return sprintf ("%04d%02d%02d",$this->year,$this->month,$this->day); } /** * get date formatted as MONTH DAY * used in watchlist */ function getMMDD() { if ( $this->notime == 1) { return "----"; } return sprintf ("%02d%02d",$this->month,$this->day); } /* --------------------------------------------------------------------------- */ function getYYYYMMDDHHMM() { if ( $this->notime == 1) { return "------------"; } return sprintf ("%04d%02d%02d%02d%02d",$this->year,$this->month,$this->day,$this->hour,$this->min); } /* --------------------------------------------------------------------------- */ function getYYYYMMDDHHMMSS_crm() { if ( $this->notime == 1) { return "------------"; } return sprintf ("%04d-%02d-%02d %02d:%02d:%02d",$this->year,$this->month,$this->day,$this->hour,$this->min,$this->sec); } /* --------------------------------------------------------------------------- */ function getYYYYMMDDHHMMSS() { if ( $this->notime == 1) { return "------------"; } return sprintf ("%04d%02d%02d%02d%02d%02d",$this->year,$this->month,$this->day,$this->hour,$this->min,$this->sec); } /* --------------------------------------------------------------------------- */ function getLinkDateTime() { global $current_user; if ( $this->notime == 1) { return "------"; } if ( $current_user->feature_ok(usecalendar,PERM_SEE) ) { return makelink("calendar.php?t=".$this->getYYYYMMDD(),$this->getDateTime(),$this->getDateTime()); } else { return $this->getDateTime(); } } /* --------------------------------------------------------------------------- */ function getLinkDate() { global $current_user; if ( $this->notime == 1) { return "------"; } if ( $current_user->feature_ok(usecalendar,PERM_SEE) ) { return makelink("calendar.php?t=".$this->getYYYYMMDD(),$this->getDate(),$this->getDate()); } else { return $this->getDate(); } } /** * Data of XML export */ function exportXML_body () { return $this->getYYYYMMDDHHMMSS(); } /** * add given number of days to this date */ function addDays($val) { if ( $this->notime == 1) { return -1; } $ts = mktime($this->hour,$this->min,$this->sec,$this->month,$this->day + $val ,$this->year); $this->setDateTimeTS($ts); } /** * add given number of days to this date */ function isWorkday(&$pref) { if ( $this->notime == 1) { return 0; } $wd = Date("w",$this->ts); if ($pref->isWorkDay($wd)) { return 1; } return 0; } /** * get a unix timestamp */ function getTimestamp() { if ( $this->notime == 1) { return -1; } return mktime($this->hour,$this->min,$this->sec,$this->month,$this->day,$this->year); } /** * get DateTime formatted for ical */ function getIcal() { if ( $this->notime == 1) { return ""; } # contrib by Danilo Beuche # UH HU THIS IS A BAD HACK, BUT iCal Times have to be in UTC $x = mktime($this->hour,$this->min,$this->sec,$this->month,$this->day,$this->year); $y = gmmktime($this->hour,$this->min,$this->sec,$this->month,$this->day,$this->year); $diff = $y - $x; return strftime("%Y%m%dT%H%M%SZ",$x - $diff); # return sprintf ("%04d%02d%02dT%02d%02d%02dZ",$this->year,$this->month,$this->day,$this->hour,$this->min,$this->sec); } function lessthan( &$DateObj ) { return( $this->ts < $DateObj->ts ); } /* Ala strcmp : returns <0, 0 or >0... */ function datecmp( &$DateObj ) { return $this->ts - $DateObj->ts; } } ?>