Ticket #1443 (new defect)

Opened 15 months ago

Last modified 7 days ago

[PATCH] Date::setValue()

Reported by: xmedeko Owned by: sminnee
Priority: trivial Milestone:
Component: Sapphire Framework Version:
Severity: medium effort / impact Keywords:
Cc: Hours:

Description (last modified by ischommer) (diff)

the setValue() method in Date class is [code php] function setValue($value) { if( is_array( $value ) && $valueDay? && $valueMonth? && $valueYear? ) { $this->value = $valueYear? . '-' . $valueMonth? . '-' . $valueDay?; return; }

// Default to NZ date format - strtotime expects a US date if(ereg('([0-9]+)/([0-9]+)/([0-9]+)$', $value, $parts)) $value = "$parts[2]/$parts[1]/$parts[3]";

if($value) $this->value = date('Y-m-d', strtotime($value)); else $value = null; }

But the lines [code php] // Default to NZ date format - strtotime expects a US date if(ereg('([0-9]+)/([0-9]+)/([0-9]+)$', $value, $parts)) $value = "$parts[2]/$parts[1]/$parts[3]";

do not work, because of the code [code php] if($value) $this->value = date('Y-m-d', strtotime($value));

So, if I set the date to '23/07/2007', then the date in DB is 0000-00-00.

see http://www.silverstripe.com/bugs/flat/2824

Change History

Changed 7 days ago by ischommer

  • description modified (diff)
Note: See TracTickets for help on using tickets.