本文整理汇总了PHP中PHPExcel_Shared_Date::getExcelCalendar方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Shared_Date::getExcelCalendar方法的具体用法?PHP PHPExcel_Shared_Date::getExcelCalendar怎么用?PHP PHPExcel_Shared_Date::getExcelCalendar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Shared_Date
的用法示例。
在下文中一共展示了PHPExcel_Shared_Date::getExcelCalendar方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: TIME
/**
* TIME
*
* @param long $hour
* @param long $minute
* @param long $second
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function TIME($hour = 0, $minute = 0, $second = 0)
{
$hour = self::flattenSingleValue($hour);
$minute = self::flattenSingleValue($minute);
$second = self::flattenSingleValue($second);
if ($hour == '') {
$hour = 0;
}
if ($minute == '') {
$minute = 0;
}
if ($second == '') {
$second = 0;
}
if (!is_numeric($hour) || !is_numeric($minute) || !is_numeric($second)) {
return self::$_errorCodes['value'];
}
$hour = (int) $hour;
$minute = (int) $minute;
$second = (int) $second;
if ($second < 0) {
$minute += floor($second / 60);
$second = 60 - abs($second % 60);
if ($second == 60) {
$second = 0;
}
} elseif ($second >= 60) {
$minute += floor($second / 60);
$second = $second % 60;
}
if ($minute < 0) {
$hour += floor($minute / 60);
$minute = 60 - abs($minute % 60);
if ($minute == 60) {
$minute = 0;
}
} elseif ($minute >= 60) {
$hour += floor($minute / 60);
$minute = $minute % 60;
}
if ($hour > 23) {
$hour = $hour % 24;
} elseif ($hour < 0) {
return self::$_errorCodes['num'];
}
// Execute function
switch (self::getReturnDateType()) {
case self::RETURNDATE_EXCEL:
$date = 0;
$calendar = PHPExcel_Shared_Date::getExcelCalendar();
if ($calendar != PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900) {
$date = 1;
}
return (double) PHPExcel_Shared_Date::FormattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second);
break;
case self::RETURNDATE_PHP_NUMERIC:
return (int) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::FormattedPHPToExcel(1970, 1, 1, $hour - 1, $minute, $second));
// -2147468400; // -2147472000 + 3600
break;
case self::RETURNDATE_PHP_OBJECT:
$dayAdjust = 0;
if ($hour < 0) {
$dayAdjust = floor($hour / 24);
$hour = 24 - abs($hour % 24);
if ($hour == 24) {
$hour = 0;
}
} elseif ($hour >= 24) {
$dayAdjust = floor($hour / 24);
$hour = $hour % 24;
}
$phpDateObject = new DateTime('1900-01-01 ' . $hour . ':' . $minute . ':' . $second);
if ($dayAdjust != 0) {
$phpDateObject->modify($dayAdjust . ' days');
}
return $phpDateObject;
break;
}
}
示例2: _writeWorkbookPr
/**
* Write WorkbookPr
*
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @throws PHPExcel_Writer_Exception
*/
private function _writeWorkbookPr(PHPExcel_Shared_XMLWriter $objWriter = null)
{
$objWriter->startElement('workbookPr');
if (PHPExcel_Shared_Date::getExcelCalendar() == PHPExcel_Shared_Date::CALENDAR_MAC_1904) {
$objWriter->writeAttribute('date1904', '1');
}
$objWriter->writeAttribute('codeName', 'ThisWorkbook');
$objWriter->endElement();
}
示例3: writeDateMode
/**
* Write DATEMODE record to indicate the date system in use (1904 or 1900).
*/
private function writeDateMode()
{
$record = 0x22;
// Record identifier
$length = 0x2;
// Bytes to follow
$f1904 = PHPExcel_Shared_Date::getExcelCalendar() == PHPExcel_Shared_Date::CALENDAR_MAC_1904 ? 1 : 0;
// Flag for 1904 date system
$header = pack("vv", $record, $length);
$data = pack("v", $f1904);
$this->append($header . $data);
}