示例#1
0
 public function stringToDate($data)
 {
     if (get_class($data) == 'SDate') {
         return $data;
     }
     try {
         $date = SDate::parse($data);
     } catch (Exception $e) {
         return null;
     }
     return $date;
 }
示例#2
0
 public function testParsing()
 {
     $this->assertEqual(new SDate(1969, 7, 21), SDate::parse('1969-07-21'));
     $this->assertEqual(new SDateTime(1969, 7, 21, 20, 35, 05), SDateTime::parse('19690721T20:35:05'));
     $this->assertEqual(new SDateTime(1969, 7, 21, 20, 35, 05), SDateTime::parse('1969-07-21 20:35:05'));
 }