コード例 #1
0
ファイル: Workbook.php プロジェクト: kameshwariv/testexample
 /**
  * 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);
 }
コード例 #2
0
ファイル: Workbook.php プロジェクト: kameshwariv/testexample
 /**
  * Write WorkbookPr
  *
  * @param     \PHPExcel\Shared\XMLWriter $objWriter         XML Writer
  * @throws     \PHPExcel\Writer\Exception
  */
 private function writeWorkbookPr(\PHPExcel\Shared\XMLWriter $objWriter)
 {
     $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
0
ファイル: DateTime.php プロジェクト: kameshwariv/testexample
 /**
  * TIME
  *
  * The TIME function returns a value that represents a particular time.
  *
  * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time
  * format of your regional settings. PHPExcel does not change cell formatting in this way.
  *
  * Excel Function:
  *        TIME(hour,minute,second)
  *
  * @access    public
  * @category Date/Time Functions
  * @param    integer        $hour        A number from 0 (zero) to 32767 representing the hour.
  *                                    Any value greater than 23 will be divided by 24 and the remainder
  *                                    will be treated as the hour value. For example, TIME(27,0,0) =
  *                                    TIME(3,0,0) = .125 or 3:00 AM.
  * @param    integer        $minute        A number from 0 to 32767 representing the minute.
  *                                    Any value greater than 59 will be converted to hours and minutes.
  *                                    For example, TIME(0,750,0) = TIME(12,30,0) = .520833 or 12:30 PM.
  * @param    integer        $second        A number from 0 to 32767 representing the second.
  *                                    Any value greater than 59 will be converted to hours, minutes,
  *                                    and seconds. For example, TIME(0,0,2000) = TIME(0,33,22) = .023148
  *                                    or 12:33:20 AM
  * @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 = Functions::flattenSingleValue($hour);
     $minute = Functions::flattenSingleValue($minute);
     $second = Functions::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 Functions::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 Functions::NAN();
     }
     // Execute function
     switch (Functions::getReturnDateType()) {
         case Functions::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);
         case Functions::RETURNDATE_PHP_NUMERIC:
             return (int) \PHPExcel\Shared\Date::excelToPHP(\PHPExcel\Shared\Date::formattedPHPToExcel(1970, 1, 1, $hour, $minute, $second));
             // -2147468400; //    -2147472000 + 3600
         // -2147468400; //    -2147472000 + 3600
         case Functions::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;
     }
 }