当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPExcel_Shared_Date::getExcelCalendar方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:linhanwei,项目名称:TP,代码行数:88,代码来源:Functions.php

示例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();
 }
开发者ID:Princelo,项目名称:bioerp,代码行数:15,代码来源:Workbook.php

示例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);
 }
开发者ID:jaya-project,项目名称:zycms,代码行数:15,代码来源:Workbook.php


注:本文中的PHPExcel_Shared_Date::getExcelCalendar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。