/** * iCal spec represents date in ISO 8601 format followed by "T" then the time * a "Z at the end means the time is UTC and not local time zone * * TODO make sure if time is UTC we take account of system time offset properly * */ function unixTime($ical_date, $tz = false) { jimport("joomla.utilities.date"); static $offset = null; if (is_null($offset)) { $config =& JFactory::getConfig(); $offset = $config->getValue('config.offset', 0); } if (!is_numeric($ical_date)) { $t = JevDate::strtotime($ical_date); if (JString::strpos($ical_date, "Z") > 0) { if (is_callable("date_default_timezone_set")) { $timezone = date_default_timezone_get(); // See http://www.php.net/manual/en/timezones.php $params = JComponentHelper::getParams(JEV_COM_COMPONENT); // server offset tiemzone if ($params->get("icaltimezone", "") != "") { date_default_timezone_set($params->get("icaltimezone", "")); } // server offset PARAMS $serveroffset1 = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S', $t)) - JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ', $t))) / 3600; // server offset SERVER date_default_timezone_set($timezone); $serveroffset2 = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S', $t)) - JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ', $t))) / 3600; $t = new JevDate($ical_date, $serveroffset1 - $serveroffset2); //$t = new JevDate($ical_date ); date_default_timezone_set($timezone); echo "icaldate = " . $ical_date . " imported date=" . $t->toMySQL() . "<br/>"; } else { // Summer Time adjustment list($y, $m, $d, $h, $min, $s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S', $t)); $dst = (JevDate::mktime($h, $min, $s, $m, $d, $y, 0) - JevDate::mktime($h, $min, $s, $m, $d, $y, -1)) / 3600; // server offset including DST $serveroffset = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S', $t)) - JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ', $t))) / 3600; $serveroffset += $dst; $t = new JevDate($ical_date, -($serveroffset + $offset)); } /* echo "<h3>SET TIMEZONE</h3>"; $timezone= date_default_timezone_get(); date_default_timezone_set('America/New_York'); $tempIcal = "20091020T163000Z"; echo $tempIcal."<br/>"; $temp = JevDate::strtotime($tempIcal); list($y,$m,$d,$h,$min,$s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S',$temp)); echo "$y,$m,$d,$h,$min,$s<br/>"; $dst = (JevDate::mktime($h,$min,$s,$m,$d,$y,0)-JevDate::mktime($h,$min,$s,$m,$d,$y,-1))/3600; $so = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S',$temp))-JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ',$temp)))/3600; echo " dst=".$dst." serverforoffset=".$so."<br/>"; $so += $dst; $t = new JevDate($tempIcal); echo $t->toMySQL()."<br><br/>"; $tempIcal = "20091029T163000Z"; echo $tempIcal."<br/>"; $temp = JevDate::strtotime($tempIcal); list($y,$m,$d,$h,$min,$s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S',$temp)); echo "$y,$m,$d,$h,$min,$s<br/>"; $dst = (JevDate::mktime($h,$min,$s,$m,$d,$y,0)-JevDate::mktime($h,$min,$s,$m,$d,$y,-1))/3600; $so = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S',$temp))-JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ',$temp)))/3600; echo " dst=".$dst." serverforoffset=".$so."<br/>"; $so += $dst; $t = new JevDate($tempIcal ); echo $t->toMySQL()."<br><br/>"; $tempIcal = "20091103T163000Z"; echo $tempIcal."<br/>"; $temp = JevDate::strtotime($tempIcal); list($y,$m,$d,$h,$min,$s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S',$temp)); echo "$y,$m,$d,$h,$min,$s<br/>"; $dst = (JevDate::mktime($h,$min,$s,$m,$d,$y,0)-JevDate::mktime($h,$min,$s,$m,$d,$y,-1))/3600; $so = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S',$temp))-JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ',$temp)))/3600; echo " dst=".$dst." serverforoffset=".$so."<br/>"; $so += $dst; $t = new JevDate($tempIcal); echo $t->toMySQL()."<br>"; */ } else { if ($tz != false && $tz != "") { // really should use the timezone of the inputted date $tz = new DateTimeZone($tz); $t = new JevDate($ical_date, $tz); echo "icaldate = " . $ical_date . " imported date=" . $t->toMySQL() . "<br/>"; } else { $compparams = JComponentHelper::getParams(JEV_COM_COMPONENT); $jtz = $compparams->get("icaltimezonelive", ""); if ($jtz) { $t = new JevDate($ical_date, $jtz); } else { $t = new JevDate($ical_date); } } } //$result = $t->toMySQL(); $result = $t->toUnix(); return $result; } $isUTC = false; if (JString::strpos($ical_date, "Z") !== false) { $isUTC = true; } // strip "T" and "Z" from the string $ical_date = str_replace('T', '', $ical_date); $ical_date = str_replace('Z', '', $ical_date); // split it out intyo YYYY MM DD HH MM SS preg_match("#([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})#", $ical_date, $date); list($temp, $y, $m, $d, $h, $min, $s) = $date; if (!$min) { $min = 0; } if (!$h) { $h = 0; } if (!$d) { $d = 0; } if (!$s) { $s = 0; } // Trap unix dated beofre 1970 $y = max($y, 1970); if ($isUTC) { $t = gmJevDate::mktime($h, $min, $s, $m, $d, $y) + 3600 * $offset; $result = JevDate::strtotime(gmdate('Y-m-d H:i:s', $t)); } else { $result = JevDate::mktime($h, $min, $s, $m, $d, $y); } // double check!! //list($y1,$m1,$d1,$h1,$min1,$s1)=explode(":",JevDate::strftime('%Y:%m:%d:%H:%M:%S',$result)); return $result; }
function maprpts() { $db =& JFactory::getDBO(); $db->setQuery("delete from jos_repbyday"); $db->query(); $db->setQuery("SELECT rpt.rp_id, rpt.startrepeat, rpt.endrepeat, evt.catid FROM #__jevents_repetition as rpt LEFT JOIN #__jevents_vevent as evt ON rpt.eventid=evt.ev_id"); $rpts = $db->loadObjectList(); jimport("joomla.utilities.date"); foreach ($rpts as $rpt) { $startday = new JevDate(substr($rpt->startrepeat, 0, 10)); $endday = new JevDate(substr($rpt->endrepeat, 0, 10)); while ($endday->toUnix() >= $startday->toUnix()) { $db->setQuery("replace into jos_jevents_repbyday (rptday,rp_id,catid) values('" . $startday->toFormat('%Y-%m-%d') . "'," . $rpt->rp_id . "," . $rpt->catid . ")"); $db->query(); $startday = new JevDate($startday->toUnix() + 86400); } } }
$item_organizer = html_entity_decode( $item_organizer ); // location for particular item $item_location = htmlspecialchars( $row->location() ); $item_location = html_entity_decode( $item_location ); // start date for particular item $item_startdate = htmlspecialchars( $row->publish_up()); // end date for particular item $item_enddate = htmlspecialchars( $row->publish_down() ); if (isset($row->_thumbimg1) && $row->_thumbimg1!=""){ $item_description = $row->_thumbimg1. "<br/>".$item_description; } */ // load individual item creator class $item = new JFeedItem(); // item info if ($row->alldayevent()) { $temptime = new JevDate($eventDate); $item->title = $temptime->toFormat(JText::_('JEV_RSS_DATE')) . " : " . $item_title; } else { $temptime = new JevDate($eventDate); $item->title = $temptime->toFormat(JText::_('JEV_RSS_DATETIME')) . " : " . $item_title; } $item->link = $item_link; $item->description = $item_description; $item->category = $item_type; $eventcreated = new JevDate($row->created()); $item->date = $eventcreated->toUnix(true); // add item info to RSS document $doc->addItem($item); } }
$item_organizer = html_entity_decode( $item_organizer ); // location for particular item $item_location = htmlspecialchars( $row->location() ); $item_location = html_entity_decode( $item_location ); // start date for particular item $item_startdate = htmlspecialchars( $row->publish_up()); // end date for particular item $item_enddate = htmlspecialchars( $row->publish_down() ); if (isset($row->_thumbimg1) && $row->_thumbimg1!=""){ $item_description = $row->_thumbimg1. "<br/>".$item_description; } */ // load individual item creator class $item = new JFeedItem(); // item info if ($row->alldayevent()) { $temptime = new JevDate($eventDate); $item->set('title', $temptime->toFormat(JText::_('JEV_RSS_DATE')) . " : " . $item_title); } else { $temptime = new JevDate($eventDate); $item->set('title', $temptime->toFormat(JText::_('JEV_RSS_DATETIME')) . " : " . $item_title); } $item->set('link', $item_link); $item->set('description', $item_description); $item->set('category', $item_type); $eventcreated = new JevDate($row->created()); $item->set('date', $eventcreated->toUnix(true)); // add item info to RSS document $doc->addItem($item); } }