Fix to date properties when set as a formatted string

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@63424 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2010-11-07 16:08:27 +00:00
parent 98e7fa5a6a
commit b818187d3c

View File

@ -122,310 +122,324 @@ class PHPExcel_DocumentProperties
private $_customProperties = array(); private $_customProperties = array();
/** /**
* Create a new PHPExcel_DocumentProperties * Create a new PHPExcel_DocumentProperties
*/ */
public function __construct() public function __construct()
{ {
// Initialise values // Initialise values
$this->_creator = 'Unknown Creator'; $this->_creator = 'Unknown Creator';
$this->_lastModifiedBy = $this->_creator; $this->_lastModifiedBy = $this->_creator;
$this->_created = time(); $this->_created = time();
$this->_modified = time(); $this->_modified = time();
$this->_title = "Untitled Spreadsheet"; $this->_title = "Untitled Spreadsheet";
$this->_subject = ''; $this->_subject = '';
$this->_description = ''; $this->_description = '';
$this->_keywords = ''; $this->_keywords = '';
$this->_category = ''; $this->_category = '';
$this->_manager = ''; $this->_manager = '';
$this->_company = 'Microsoft Corporation'; $this->_company = 'Microsoft Corporation';
} }
/** /**
* Get Creator * Get Creator
* *
* @return string * @return string
*/ */
public function getCreator() { public function getCreator() {
return $this->_creator; return $this->_creator;
} }
/** /**
* Set Creator * Set Creator
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel_DocumentProperties
*/ */
public function setCreator($pValue = '') { public function setCreator($pValue = '') {
$this->_creator = $pValue; $this->_creator = $pValue;
return $this; return $this;
} }
/** /**
* Get Last Modified By * Get Last Modified By
* *
* @return string * @return string
*/ */
public function getLastModifiedBy() { public function getLastModifiedBy() {
return $this->_lastModifiedBy; return $this->_lastModifiedBy;
} }
/** /**
* Set Last Modified By * Set Last Modified By
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel_DocumentProperties
*/ */
public function setLastModifiedBy($pValue = '') { public function setLastModifiedBy($pValue = '') {
$this->_lastModifiedBy = $pValue; $this->_lastModifiedBy = $pValue;
return $this; return $this;
} }
/** /**
* Get Created * Get Created
* *
* @return datetime * @return datetime
*/ */
public function getCreated() { public function getCreated() {
return $this->_created; return $this->_created;
} }
/** /**
* Set Created * Set Created
* *
* @param datetime $pValue * @param datetime $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel_DocumentProperties
*/ */
public function setCreated($pValue = null) { public function setCreated($pValue = null) {
if (is_null($pValue)) { if (is_null($pValue)) {
$pValue = time(); $pValue = time();
} } elseif (is_string($pValue)) {
$this->_created = $pValue; if (is_numeric($pValue)) {
return $this; $pValue = intval($pValue);
} } else {
$pValue = strtotime($pValue);
}
}
/** $this->_created = $pValue;
* Get Modified return $this;
* }
* @return datetime
*/
public function getModified() {
return $this->_modified;
}
/** /**
* Set Modified * Get Modified
* *
* @param datetime $pValue * @return datetime
* @return PHPExcel_DocumentProperties */
*/ public function getModified() {
public function setModified($pValue = null) { return $this->_modified;
if (is_null($pValue)) { }
$pValue = time();
}
$this->_modified = $pValue;
return $this;
}
/** /**
* Get Title * Set Modified
* *
* @return string * @param datetime $pValue
*/ * @return PHPExcel_DocumentProperties
public function getTitle() { */
return $this->_title; public function setModified($pValue = null) {
} if (is_null($pValue)) {
$pValue = time();
} elseif (is_string($pValue)) {
if (is_numeric($pValue)) {
$pValue = intval($pValue);
} else {
$pValue = strtotime($pValue);
}
}
/** $this->_modified = $pValue;
* Set Title return $this;
* }
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setTitle($pValue = '') {
$this->_title = $pValue;
return $this;
}
/** /**
* Get Description * Get Title
* *
* @return string * @return string
*/ */
public function getDescription() { public function getTitle() {
return $this->_description; return $this->_title;
} }
/** /**
* Set Description * Set Title
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel_DocumentProperties
*/ */
public function setDescription($pValue = '') { public function setTitle($pValue = '') {
$this->_description = $pValue; $this->_title = $pValue;
return $this; return $this;
} }
/** /**
* Get Subject * Get Description
* *
* @return string * @return string
*/ */
public function getSubject() { public function getDescription() {
return $this->_subject; return $this->_description;
} }
/** /**
* Set Subject * Set Description
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel_DocumentProperties
*/ */
public function setSubject($pValue = '') { public function setDescription($pValue = '') {
$this->_subject = $pValue; $this->_description = $pValue;
return $this; return $this;
} }
/** /**
* Get Keywords * Get Subject
* *
* @return string * @return string
*/ */
public function getKeywords() { public function getSubject() {
return $this->_keywords; return $this->_subject;
} }
/** /**
* Set Keywords * Set Subject
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel_DocumentProperties
*/ */
public function setKeywords($pValue = '') { public function setSubject($pValue = '') {
$this->_keywords = $pValue; $this->_subject = $pValue;
return $this; return $this;
} }
/** /**
* Get Category * Get Keywords
* *
* @return string * @return string
*/ */
public function getCategory() { public function getKeywords() {
return $this->_category; return $this->_keywords;
} }
/** /**
* Set Category * Set Keywords
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel_DocumentProperties
*/ */
public function setCategory($pValue = '') { public function setKeywords($pValue = '') {
$this->_category = $pValue; $this->_keywords = $pValue;
return $this; return $this;
} }
/** /**
* Get Company * Get Category
* *
* @return string * @return string
*/ */
public function getCompany() { public function getCategory() {
return $this->_company; return $this->_category;
} }
/** /**
* Set Company * Set Category
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel_DocumentProperties
*/ */
public function setCompany($pValue = '') { public function setCategory($pValue = '') {
$this->_company = $pValue; $this->_category = $pValue;
return $this; return $this;
} }
/** /**
* Get Manager * Get Company
* *
* @return string * @return string
*/ */
public function getManager() { public function getCompany() {
return $this->_manager; return $this->_company;
} }
/** /**
* Set Manager * Set Company
* *
* @param string $pValue * @param string $pValue
* @return PHPExcel_DocumentProperties * @return PHPExcel_DocumentProperties
*/ */
public function setManager($pValue = '') { public function setCompany($pValue = '') {
$this->_manager = $pValue; $this->_company = $pValue;
return $this; return $this;
} }
/** /**
* Get a List of Custom Property Names * Get Manager
* *
* @return array of string * @return string
*/ */
public function getCustomProperties() { public function getManager() {
return $this->_manager;
}
/**
* Set Manager
*
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setManager($pValue = '') {
$this->_manager = $pValue;
return $this;
}
/**
* Get a List of Custom Property Names
*
* @return array of string
*/
public function getCustomProperties() {
return array_keys($this->_customProperties); return array_keys($this->_customProperties);
} }
/** /**
* Check if a Custom Property is defined * Check if a Custom Property is defined
* *
* @param string $propertyName * @param string $propertyName
* @return boolean * @return boolean
*/ */
public function isCustomPropertySet($propertyName) { public function isCustomPropertySet($propertyName) {
return isset($this->_customProperties[$propertyName]); return isset($this->_customProperties[$propertyName]);
} }
/** /**
* Get a Custom Property Value * Get a Custom Property Value
* *
* @param string $propertyName * @param string $propertyName
* @return string * @return string
*/ */
public function getCustomPropertyValue($propertyName) { public function getCustomPropertyValue($propertyName) {
if (isset($this->_customProperties[$propertyName])) { if (isset($this->_customProperties[$propertyName])) {
return $this->_customProperties[$propertyName]['value']; return $this->_customProperties[$propertyName]['value'];
} }
} }
/** /**
* Get a Custom Property Type * Get a Custom Property Type
* *
* @param string $propertyName * @param string $propertyName
* @return string * @return string
*/ */
public function getCustomPropertyType($propertyName) { public function getCustomPropertyType($propertyName) {
if (isset($this->_customProperties[$propertyName])) { if (isset($this->_customProperties[$propertyName])) {
return $this->_customProperties[$propertyName]['type']; return $this->_customProperties[$propertyName]['type'];
} }
} }
/** /**
* Set a Custom Property * Set a Custom Property
* *
* @param string $propertyName * @param string $propertyName
* @param mixed $propertyValue * @param mixed $propertyValue
* @param string $propertyType * @param string $propertyType
* 'i' : Integer * 'i' : Integer
* 'f' : Floating Point * 'f' : Floating Point
* 's' : String * 's' : String
* 'd' : Date/Time * 'd' : Date/Time
* 'b' : Boolean * 'b' : Boolean
* @return PHPExcel_DocumentProperties * @return PHPExcel_DocumentProperties
*/ */
public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) { public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) {
if ((is_null($propertyType)) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER, if ((is_null($propertyType)) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER,
self::PROPERTY_TYPE_FLOAT, self::PROPERTY_TYPE_FLOAT,
self::PROPERTY_TYPE_STRING, self::PROPERTY_TYPE_STRING,
@ -445,8 +459,8 @@ class PHPExcel_DocumentProperties
} }
$this->_customProperties[$propertyName] = array('value' => $propertyValue, 'type' => $propertyType); $this->_customProperties[$propertyName] = array('value' => $propertyValue, 'type' => $propertyType);
return $this; return $this;
} }
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Implement PHP __clone to create a deep clone, not just a shallow copy.