Permalink
Browse files

MINOR added Rfc2822 method to SS_Datetime. Fixed bug where dates in D…

…ataObject would not set times. (from r100032)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@105546 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 052f71f commit 3bd114256b518d4ac5800dda7397fd9b35447851 @chillu chillu committed May 25, 2010
Showing with 8 additions and 4 deletions.
  1. +4 −4 core/model/DataObject.php
  2. +4 −0 core/model/fieldtypes/Date.php
@@ -1013,9 +1013,9 @@ public function write($showDebug = false, $forceInsert = false, $forceWrite = fa
// Add the class name to the base object
if($idx == 0) {
- $manipulation[$class]['fields']["LastEdited"] = SS_Datetime::now()->URLDate();
+ $manipulation[$class]['fields']["LastEdited"] = "'".SS_Datetime::now()->Rfc2822()."'";
if($dbCommand == 'insert') {
- $manipulation[$class]['fields']["Created"] = SS_Datetime::now()->URLDate();
+ $manipulation[$class]['fields']["Created"] = "'".SS_Datetime::now()->Rfc2822()."'";
//echo "<li>$this->class - " .get_class($this);
$manipulation[$class]['fields']["ClassName"] = "'$this->class'";
}
@@ -1057,9 +1057,9 @@ public function write($showDebug = false, $forceInsert = false, $forceWrite = fa
$this->flushCache();
if(!isset($this->record['Created'])) {
- $this->record['Created'] = SS_Datetime::now()->URLDate();
+ $this->record['Created'] = SS_Datetime::now()->Rfc2822();
}
- $this->record['LastEdited'] = SS_Datetime::now()->URLDate();
+ $this->record['LastEdited'] = SS_Datetime::now()->Rfc2822();
}
// Write ComponentSets as necessary
@@ -131,6 +131,10 @@ function Rfc822() {
if($this->value) return date('r', strtotime($this->value));
}
+ function Rfc2822() {
+ if($this->value) return date('Y-m-d g:i:s', strtotime($this->value));
+ }
+
function Rfc3339() {
$timestamp = ($this->value) ? strtotime($this->value) : false;
if(!$timestamp) return false;

0 comments on commit 3bd1142

Please sign in to comment.