/** * This method extract a date string formatted for ganttchart from a SMWTimeValue object. * * @param $dv SMWTimeValue, date that is to be converted * @return string in form MM/DD/YYYY HH:MM:SS */ public function getGanttDate(SMWTimeValue $dv, $isend = false) { $year = $dv->getYear(); if ($year > 9999 || $year < -9998) { return ''; } // ISO range is limited to four digits $year = number_format($year, 0, '.', ''); $time = $dv->getTimeString(false); if ($time == false && $isend) { // increment by one day, compute date to cover leap years etc. $dv = SMWDataValueFactory::newTypeIDValue('_dat', $dv->getWikiValue() . 'T00:00:00+24:00'); } $month = $dv->getMonth(); if (strlen($month) == 1) { $month = '0' . $month; } $day = $dv->getDay(); if (strlen($day) == 1) { $day = '0' . $day; } $result = $month . '/' . $day . '/' . $year; if ($time != false) { $result .= " {$time}"; } return $result; }
/** * Extract a date string formatted for iCalendar from a SMWTimeValue object. */ static private function parsedate( SMWTimeValue $dv, $isend = false ) { $year = $dv->getYear(); if ( ( $year > 9999 ) || ( $year < -9998 ) ) return ''; // ISO range is limited to four digits $year = number_format( $year, 0, '.', '' ); $time = str_replace( ':', '', $dv->getTimeString( false ) ); if ( ( $time == false ) && ( $isend ) ) { // increment by one day, compute date to cover leap years etc. $dv = SMWDataValueFactory::newTypeIDValue( '_dat', $dv->getWikiValue() . 'T00:00:00-24:00' ); } $month = $dv->getMonth(); if ( strlen( $month ) == 1 ) $month = '0' . $month; $day = $dv->getDay(); if ( strlen( $day ) == 1 ) $day = '0' . $day; $result = $year . $month . $day; if ( $time != false ) $result .= "T$time"; return $result; }