示例#1
0
 public function testGetCalFormats()
 {
     $cal_tests = array(array("df" => "Y-m-d", "caldf" => "%Y-%m-%d", "tf" => "H:i:s", "caltf" => "%H:%M:%S"), array("df" => "d/m/Y", "caldf" => "%d/%m/%Y", "tf" => "h:i:sa", "caltf" => "%I:%M:%S%P"), array("df" => "m/d/Y", "caldf" => "%m/%d/%Y", "tf" => "H:i", "caltf" => "%H:%M"), array("df" => "Y-m-d", "caldf" => "%Y-%m-%d", "tf" => "h:iA", "caltf" => "%I:%M%p"));
     foreach ($cal_tests as $datetest) {
         $this->_setPrefs($datetest["df"], $datetest["tf"], "America/Los_Angeles");
         $this->assertEquals($datetest["caldf"], $this->time_date->get_cal_date_format(), "Bad cal date format for '{$datetest["df"]}'");
         $this->assertEquals($datetest["caltf"], $this->time_date->get_cal_time_format(), "Bad cal time format for '{$datetest["tf"]}'");
         $this->assertEquals($this->time_date->merge_date_time($datetest["caldf"], $datetest["caltf"]), $this->time_date->get_cal_date_time_format(), "Bad cal datetime format for '{$datetest["df"]} {$datetest["tf"]}'");
     }
 }
示例#2
0
 /**
  * This function retrieves a record of the appropriate type from the DB.
  * It fills in all of the fields from the DB into the object it was called on.
  *
  * @param $id - If ID is specified, it overrides the current value of $this->id.  If not specified the current value of $this->id will be used.
  * @return this - The object that it was called apon or null if exactly 1 record was not found.
  *
  */
 function check_date_relationships_load()
 {
     global $disable_date_format;
     if (!empty($disable_date_format)) {
         return;
     }
     global $timedate;
     if (empty($timedate)) {
         $timedate = new TimeDate();
     }
     if (empty($this->field_defs)) {
         return;
     }
     foreach ($this->field_defs as $fieldDef) {
         $field = $fieldDef['name'];
         if (!isset($this->processed_dates_times[$field])) {
             $this->processed_dates_times[$field] = '1';
             if ($field == 'date_modified' || $field == 'date_entered') {
                 if (!empty($this->{$field})) {
                     $this->{$field} = $timedate->to_display_date_time($this->{$field});
                 }
             } elseif (!empty($this->{$field}) && isset($this->field_name_map[$field]['type'])) {
                 $type = $this->field_name_map[$field]['type'];
                 if ($type == 'relate' && isset($this->field_name_map[$field]['custom_module'])) {
                     $type = $this->field_name_map[$field]['type'];
                 }
                 if ($type == 'date') {
                     $this->{$field} = from_db_convert($this->{$field}, 'date');
                     if ($this->{$field} == '0000-00-00') {
                         $this->{$field} = '';
                     } elseif (!empty($this->field_name_map[$field]['rel_field'])) {
                         $rel_field = $this->field_name_map[$field]['rel_field'];
                         if (!empty($this->{$rel_field})) {
                             $this->{$rel_field} = from_db_convert($this->{$rel_field}, 'time');
                             $mergetime = $timedate->merge_date_time($this->{$field}, $this->{$rel_field});
                             $this->{$field} = $timedate->to_display_date($mergetime);
                             $this->{$rel_field} = $timedate->to_display_time($mergetime);
                         }
                     } else {
                         $this->{$field} = $timedate->to_display_date($this->{$field}, false);
                     }
                 } elseif ($type == 'datetime') {
                     if ($this->{$field} == '0000-00-00 00:00:00') {
                         $this->{$field} = '';
                     } else {
                         $this->{$field} = $timedate->to_display_date_time($this->{$field});
                     }
                 } elseif ($type == 'time') {
                     if ($this->{$field} == '00:00:00') {
                         $this->{$field} = '';
                     } else {
                         //$this->$field = from_db_convert($this->$field, 'time');
                         if (empty($this->field_name_map[$field]['rel_field'])) {
                             $this->{$field} = $timedate->to_display_time($this->{$field}, true, false);
                         }
                     }
                 } elseif ($type == 'encrypt') {
                     $this->{$field} = $this->decrypt_after_retrieve($this->{$field});
                 }
             }
         }
     }
 }