private function parseToTimeValueForGregorianCalendarModel(DITime $dataItem) { if ($dataItem->getYear() > 0) { $xsdvalue = str_pad($dataItem->getYear(), 4, "0", STR_PAD_LEFT); } else { $xsdvalue = '-' . str_pad(1 - $dataItem->getYear(), 4, "0", STR_PAD_LEFT); } $xsdtype = 'http://www.w3.org/2001/XMLSchema#gYear'; if ($dataItem->getPrecision() >= DITime::PREC_YM) { $xsdtype = 'http://www.w3.org/2001/XMLSchema#gYearMonth'; $xsdvalue .= '-' . str_pad($dataItem->getMonth(), 2, "0", STR_PAD_LEFT); if ($dataItem->getPrecision() >= DITime::PREC_YMD) { $xsdtype = 'http://www.w3.org/2001/XMLSchema#date'; $xsdvalue .= '-' . str_pad($dataItem->getDay(), 2, "0", STR_PAD_LEFT); if ($dataItem->getPrecision() == DITime::PREC_YMDT) { $xsdtype = 'http://www.w3.org/2001/XMLSchema#dateTime'; $xsdvalue .= 'T' . sprintf("%02d", $dataItem->getHour()) . ':' . sprintf("%02d", $dataItem->getMinute()) . ':' . sprintf("%02d", $dataItem->getSecond()); } } } $this->xsdValue = $xsdvalue .= 'Z'; $this->xsdType = $xsdtype; }
private function parseToTimeValueForGregorianCalendarModel(DITime $dataItem) { if ($dataItem->getYear() > 0) { $xsdvalue = str_pad($dataItem->getYear(), 4, "0", STR_PAD_LEFT); } else { $xsdvalue = '-' . str_pad(1 - $dataItem->getYear(), 4, "0", STR_PAD_LEFT); } $xsdtype = 'http://www.w3.org/2001/XMLSchema#gYear'; if ($dataItem->getPrecision() >= DITime::PREC_YM) { $xsdtype = 'http://www.w3.org/2001/XMLSchema#gYearMonth'; $xsdvalue .= '-' . str_pad($dataItem->getMonth(), 2, "0", STR_PAD_LEFT); if ($dataItem->getPrecision() >= DITime::PREC_YMD) { $xsdtype = 'http://www.w3.org/2001/XMLSchema#date'; $xsdvalue .= '-' . str_pad($dataItem->getDay(), 2, "0", STR_PAD_LEFT); if ($dataItem->getPrecision() == DITime::PREC_YMDT) { $xsdtype = 'http://www.w3.org/2001/XMLSchema#dateTime'; $xsdvalue .= 'T' . sprintf("%02d", $dataItem->getHour()) . ':' . sprintf("%02d", $dataItem->getMinute()) . ':' . sprintf("%02d", $dataItem->getSecond()); } // https://www.w3.org/TR/2005/NOTE-timezone-20051013/ // "Time zone identification in the date and time types relies // entirely on time zone offset from UTC." // Zone offset Z indicates UTC $xsdvalue .= 'Z'; } } $this->xsdValue = $xsdvalue; $this->xsdType = $xsdtype; }