ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
PHPExcel_Shared_Date Class Reference
+ Collaboration diagram for PHPExcel_Shared_Date:

Static Public Member Functions

static setExcelCalendar ($baseDate)
 Set the Excel calendar (Windows 1900 or Mac 1904)
static getExcelCalendar ()
 Return the Excel calendar (Windows 1900 or Mac 1904)
static ExcelToPHP ($dateValue=0)
 Convert a date from Excel to PHP.
static ExcelToPHPObject ($dateValue=0)
 Convert a date from Excel to a PHP Date/Time object.
static PHPToExcel ($dateValue=0)
 Convert a date from PHP to Excel.
static FormattedPHPToExcel ($year, $month, $day, $hours=0, $minutes=0, $seconds=0)
 FormattedPHPToExcel.
static isDateTime (PHPExcel_Cell $pCell)
 Is a given cell a date/time?
static isDateTimeFormat (PHPExcel_Style_NumberFormat $pFormat)
 Is a given number format a date/time?
static isDateTimeFormatCode ($pFormatCode= '')
 Is a given number format code a date/time?

Data Fields

const CALENDAR_WINDOWS_1900 = 1900
 constants
const CALENDAR_MAC_1904 = 1904

Static Public Attributes

static $dateTimeObjectType = 'DateTime'

Static Private Attributes

static $ExcelBaseDate = self::CALENDAR_WINDOWS_1900
static $possibleDateFormatCharacters = 'ymdHis'

Detailed Description

Definition at line 52 of file Date.php.

Member Function Documentation

static PHPExcel_Shared_Date::ExcelToPHP (   $dateValue = 0)
static

Convert a date from Excel to PHP.

Parameters
long$dateValueExcel date/time value
Returns
long PHP serialized date/time

Definition at line 95 of file Date.php.

Referenced by PHPExcel_Calculation_Functions\DATE(), PHPExcel_Calculation_Functions\DATENOW(), PHPExcel_Calculation_Functions\DATEVALUE(), PHPExcel_Calculation_Functions\EDATE(), PHPExcel_Calculation_Functions\EOMONTH(), ExcelToPHPObject(), PHPExcel_Calculation_Functions\HOUROFDAY(), PHPExcel_Calculation_Functions\MINUTEOFHOUR(), PHPExcel_Calculation_Functions\SECONDOFMINUTE(), PHPExcel_Calculation_Functions\TIME(), PHPExcel_Calculation_Functions\TIMEVALUE(), PHPExcel_Style_NumberFormat\toFormattedString(), and PHPExcel_Calculation_Functions\WORKDAY().

{
if (self::$ExcelBaseDate == self::CALENDAR_WINDOWS_1900) {
$myExcelBaseDate = 25569;
// Adjust for the spurious 29-Feb-1900 (Day 60)
if ($dateValue < 60) {
--$myExcelBaseDate;
}
} else {
$myExcelBaseDate = 24107;
}
// Perform conversion
if ($dateValue >= 1) {
$utcDays = $dateValue - $myExcelBaseDate;
$returnValue = (integer) round($utcDays * 24 * 60 * 60);
} else {
$hours = round($dateValue * 24);
$mins = round($dateValue * 24 * 60) - round($hours * 60);
$secs = round($dateValue * 24 * 60 * 60) - round($hours * 60 * 60) - round($mins * 60);
$returnValue = (integer) mktime($hours, $mins, $secs);
}
// Return
return $returnValue;
} // function ExcelToPHP()

+ Here is the caller graph for this function:

static PHPExcel_Shared_Date::ExcelToPHPObject (   $dateValue = 0)
static

Convert a date from Excel to a PHP Date/Time object.

Parameters
long$dateValueExcel date/time value
Returns
long PHP date/time object

Definition at line 128 of file Date.php.

References ExcelToPHP().

Referenced by PHPExcel_Calculation_Functions\_adjustDateByMonths(), PHPExcel_Calculation_Functions\DATE(), PHPExcel_Calculation_Functions\DATEDIF(), PHPExcel_Calculation_Functions\DATENOW(), PHPExcel_Calculation_Functions\DAYOFMONTH(), PHPExcel_Calculation_Functions\DAYOFWEEK(), PHPExcel_Calculation_Functions\DAYS360(), PHPExcel_Calculation_Functions\MONTHOFYEAR(), PHPExcel_Calculation_Functions\WEEKOFYEAR(), PHPExcel_Calculation_Functions\WORKDAY(), and PHPExcel_Calculation_Functions\YEAR().

{
$dateTime = self::ExcelToPHP($dateValue);
$days = floor($dateTime / 86400);
$time = round((($dateTime / 86400) - $days) * 86400);
$hours = round($time / 3600);
$minutes = round($time / 60) - ($hours * 60);
$seconds = round($time) - ($hours * 3600) - ($minutes * 60);
$dateObj = date_create('1-Jan-1970+'.$days.' days');
$dateObj->setTime($hours,$minutes,$seconds);
return $dateObj;
} // function ExcelToPHPObject()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Shared_Date::FormattedPHPToExcel (   $year,
  $month,
  $day,
  $hours = 0,
  $minutes = 0,
  $seconds = 0 
)
static

FormattedPHPToExcel.

Parameters
long$year
long$month
long$day
long$hours
long$minutes
long$seconds
Returns
long Excel date/time value

Definition at line 178 of file Date.php.

Referenced by PHPExcel_Calculation_Functions\DATE(), PHPExcel_Calculation_Functions\DATEVALUE(), PHPToExcel(), PHPExcel_Calculation_Functions\TIME(), and PHPExcel_Calculation_Functions\TIMEVALUE().

{
if (self::$ExcelBaseDate == self::CALENDAR_WINDOWS_1900) {
//
// Fudge factor for the erroneous fact that the year 1900 is treated as a Leap Year in MS Excel
// This affects every date following 28th February 1900
//
$excel1900isLeapYear = True;
if (($year == 1900) && ($month <= 2)) { $excel1900isLeapYear = False; }
$myExcelBaseDate = 2415020;
} else {
$myExcelBaseDate = 2416481;
$excel1900isLeapYear = False;
}
// Julian base date Adjustment
if ($month > 2) {
$month = $month - 3;
} else {
$month = $month + 9;
--$year;
}
// Calculate the Julian Date, then subtract the Excel base date (JD 2415020 = 31-Dec-1899 Giving Excel Date of 0)
$century = substr($year,0,2);
$decade = substr($year,2,2);
$excelDate = floor((146097 * $century) / 4) + floor((1461 * $decade) / 4) + floor((153 * $month + 2) / 5) + $day + 1721119 - $myExcelBaseDate + $excel1900isLeapYear;
$excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400;
return (float) $excelDate + $excelTime;
} // function FormattedPHPToExcel()

+ Here is the caller graph for this function:

static PHPExcel_Shared_Date::getExcelCalendar ( )
static

Return the Excel calendar (Windows 1900 or Mac 1904)

Returns
integer $baseDate Excel base date

Definition at line 84 of file Date.php.

References $ExcelBaseDate.

Referenced by PHPExcel_Writer_Excel5_Workbook\_storeDatemode(), PHPExcel_Writer_Excel2007_Workbook\_writeWorkbookPr(), PHPExcel_Calculation_Functions\DATE(), and PHPExcel_Calculation_Functions\TIME().

{
} // function getExcelCalendar()

+ Here is the caller graph for this function:

static PHPExcel_Shared_Date::isDateTime ( PHPExcel_Cell  $pCell)
static

Is a given cell a date/time?

Parameters
PHPExcel_Cell$pCell
Returns
boolean

Definition at line 217 of file Date.php.

References PHPExcel_Cell\getCoordinate(), PHPExcel_Cell\getParent(), and isDateTimeFormat().

{
return self::isDateTimeFormat($pCell->getParent()->getStyle($pCell->getCoordinate())->getNumberFormat());
} // function isDateTime()

+ Here is the call graph for this function:

static PHPExcel_Shared_Date::isDateTimeFormat ( PHPExcel_Style_NumberFormat  $pFormat)
static

Is a given number format a date/time?

Parameters
PHPExcel_Style_NumberFormat$pFormat
Returns
boolean

Definition at line 228 of file Date.php.

References PHPExcel_Style_NumberFormat\getFormatCode(), and isDateTimeFormatCode().

Referenced by isDateTime().

{
} // function isDateTimeFormat()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Shared_Date::isDateTimeFormatCode (   $pFormatCode = '')
static

Is a given number format code a date/time?

Parameters
string$pFormatCode
Returns
boolean

Definition at line 241 of file Date.php.

References PHPExcel_Style_NumberFormat\FORMAT_DATE_DATETIME, PHPExcel_Style_NumberFormat\FORMAT_DATE_DDMMYYYY, PHPExcel_Style_NumberFormat\FORMAT_DATE_DMMINUS, PHPExcel_Style_NumberFormat\FORMAT_DATE_DMYMINUS, PHPExcel_Style_NumberFormat\FORMAT_DATE_DMYSLASH, PHPExcel_Style_NumberFormat\FORMAT_DATE_MYMINUS, PHPExcel_Style_NumberFormat\FORMAT_DATE_TIME1, PHPExcel_Style_NumberFormat\FORMAT_DATE_TIME2, PHPExcel_Style_NumberFormat\FORMAT_DATE_TIME3, PHPExcel_Style_NumberFormat\FORMAT_DATE_TIME4, PHPExcel_Style_NumberFormat\FORMAT_DATE_TIME5, PHPExcel_Style_NumberFormat\FORMAT_DATE_TIME6, PHPExcel_Style_NumberFormat\FORMAT_DATE_TIME7, PHPExcel_Style_NumberFormat\FORMAT_DATE_TIME8, PHPExcel_Style_NumberFormat\FORMAT_DATE_XLSX14, PHPExcel_Style_NumberFormat\FORMAT_DATE_XLSX15, PHPExcel_Style_NumberFormat\FORMAT_DATE_XLSX16, PHPExcel_Style_NumberFormat\FORMAT_DATE_XLSX17, PHPExcel_Style_NumberFormat\FORMAT_DATE_XLSX22, PHPExcel_Style_NumberFormat\FORMAT_DATE_YYYYMMDD, PHPExcel_Style_NumberFormat\FORMAT_DATE_YYYYMMDD2, and PHPExcel_Style_NumberFormat\FORMAT_DATE_YYYYMMDDSLASH.

Referenced by isDateTimeFormat().

{
// Switch on formatcode
switch ($pFormatCode) {
return true;
}
// Try checking for any of the date formatting characters that don't appear within square braces
if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$pFormatCode)) {
return true;
}
// No date...
return false;
} // function isDateTimeFormatCode()

+ Here is the caller graph for this function:

static PHPExcel_Shared_Date::PHPToExcel (   $dateValue = 0)
static

Convert a date from PHP to Excel.

Parameters
mixed$dateValuePHP serialized date/time or date object
Returns
mixed Excel date/time value or boolean False on failure

Definition at line 148 of file Date.php.

References elseif(), and FormattedPHPToExcel().

Referenced by PHPExcel_Calculation_Functions\_getDateValue(), PHPExcel_Cell_AdvancedValueBinder\bindValue(), PHPExcel_Calculation_Functions\DATENOW(), PHPExcel_Calculation_Functions\DATETIMENOW(), PHPExcel_Calculation_Functions\EDATE(), and PHPExcel_Calculation_Functions\EOMONTH().

{
$saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
$retValue = False;
if ((is_object($dateValue)) && ($dateValue instanceof self::$dateTimeObjectType)) {
$retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'),
$dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s')
);
} elseif (is_numeric($dateValue)) {
$retValue = self::FormattedPHPToExcel( date('Y',$dateValue), date('m',$dateValue), date('d',$dateValue),
date('H',$dateValue), date('i',$dateValue), date('s',$dateValue)
);
}
date_default_timezone_set($saveTimeZone);
return $retValue;
} // function PHPToExcel()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Shared_Date::setExcelCalendar (   $baseDate)
static

Set the Excel calendar (Windows 1900 or Mac 1904)

Parameters
integer$baseDateExcel base date
Returns
boolean Success or failure

Definition at line 69 of file Date.php.

Referenced by PHPExcel_Reader_Excel5\_readDateMode(), and PHPExcel_Reader_Excel2007\load().

{
if (($baseDate == self::CALENDAR_WINDOWS_1900) ||
($baseDate == self::CALENDAR_MAC_1904)) {
self::$ExcelBaseDate = $baseDate;
return True;
}
return False;
} // function setExcelCalendar()

+ Here is the caller graph for this function:

Field Documentation

PHPExcel_Shared_Date::$dateTimeObjectType = 'DateTime'
static

Definition at line 60 of file Date.php.

Referenced by PHPExcel_Calculation_Functions\_getDateValue().

PHPExcel_Shared_Date::$ExcelBaseDate = self::CALENDAR_WINDOWS_1900
staticprivate

Definition at line 58 of file Date.php.

Referenced by getExcelCalendar().

PHPExcel_Shared_Date::$possibleDateFormatCharacters = 'ymdHis'
staticprivate

Definition at line 233 of file Date.php.

const PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900 = 1900

The documentation for this class was generated from the following file: