Пример #1
0
 /**
  * test conversion from DB time to local time with TZ conversion
  * @dataProvider dateTestSet
  */
 public function testToDisplayTimeFormatsWithTZ($db, $df, $tf, $tz, $display, $dbdate)
 {
     if (empty($tf)) {
         return;
     }
     $this->_setPrefs($df, $tf, $tz);
     $result = $this->time_date->to_display_time($db, true, true);
     $result = $this->_timeOnly($result);
     $this->assertEquals($this->_timeOnly($display), $result, "Broken conversion for '{$tf}' with date '{$db}' and TZ {$tz}");
 }
Пример #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});
                 }
             }
         }
     }
 }
Пример #3
0
        } else {
            $dst = "";
        }
        if ($key == $defaultServerZone) {
            $selected = 'selected';
        } else {
            $selected = '';
        }
        $gmtOffset = $value['gmtOffset'] / 60;
        if (!strstr($gmtOffset, '-')) {
            $gmtOffset = "+" . $gmtOffset;
        }
        $timezoneOptions .= "<option value='{$key}'" . $selected . ">" . str_replace(array('_', 'North'), array(' ', 'N.'), $key) . " (GMT" . $gmtOffset . ") " . $dst . "</option>";
    }
    // descriptions and assumptions
    $display = "\n\t\n\t\t<tr>\n\t\t\t<td width=\"20%\" class=\"tabDetailViewDL2\" nowrap align='right'><slot>\n\t\t\t\t" . $mod_strings['LBL_DST_FIX_TARGET'] . "\n\t\t\t</slot></td>\n\t\t\t<td class=\"tabDetailViewDF2\"><slot>\n\t\t\t\t" . $mod_strings['LBL_APPLY_DST_FIX_DESC'] . "\n\t\t\t</slot></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td width=\"20%\" class=\"tabDetailViewDL2\" nowrap align='right'><slot>\n\t\t\t\t" . $mod_strings['LBL_DST_BEFORE'] . "\n\t\t\t</slot></td>\n\t\t\t<td class=\"tabDetailViewDF2\"><slot>\n\t\t\t\t" . $mod_strings['LBL_DST_BEFORE_DESC'] . "\n\t\t\t</slot></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td width=\"20%\" class=\"tabDetailViewDL2\" nowrap align='right'><slot>\n\t\t\t\t" . $mod_strings['LBL_DST_FIX_CONFIRM'] . "\n\t\t\t</slot></td>\n\t\t\t<td class=\"tabDetailViewDF2\"><slot>\n\t\t\t\t" . $mod_strings['LBL_DST_FIX_CONFIRM_DESC'] . "\n\t\t\t</slot></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td width=\"20%\" class=\"tabDetailViewDL2\" nowrap align='right'><slot>\n\t\t\n\t\t\t</slot></td>\n\t\t\t<td class=\"tabDetailViewDF2\"><slot>\n\t\t\t\t<table cellpadding='0' cellspacing='0' border='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class=\"tabDetailViewDF2\"><slot>\n\t\t\t\t\t\t\t<b>" . $mod_strings['LBL_DST_CURRENT_SERVER_TIME'] . "</b>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class=\"tabDetailViewDF2\"><slot>\n\t\t\t\t\t\t\t" . $timedate->to_display_time(date($GLOBALS['timedate']->get_db_date_time_format(), strtotime('now')), true, false) . "\n\t\t\t\t\t\t</td>\n\t\t\t\t\t<tr>\n\t\t\t\t\t</tr>\n\t\t\t\t\t\t<td class=\"tabDetailViewDF2\"><slot>\n\t\t\t\t\t\t\t<b>" . $mod_strings['LBL_DST_CURRENT_SERVER_TIME_ZONE'] . "</b>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class=\"tabDetailViewDF2\"><slot>\n\t\t\t\t\t\t\t" . date("T") . "<br>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class=\"tabDetailViewDF2\"><slot>\n\t\t\t\t\t\t\t<b>" . $mod_strings['LBL_DST_CURRENT_SERVER_TIME_ZONE_LOCALE'] . "</b>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class=\"tabDetailViewDF2\"><slot>\n\t\t\t\t\t\t\t<select name='server_timezone'>" . $timezoneOptions . "</select><br>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</slot></td>\n\t\t</tr>";
} else {
    // fix has been applied - don't want to allow a 2nd pass
    $display = $mod_strings['LBL_DST_FIX_DONE_DESC'];
    $disabled = 'DISABLED';
    $confirmed = 'false';
}
if (!empty($_POST['upgrade'])) {
    // enter row in versions table
    $qDst = "INSERT INTO versions VALUES ('" . create_guid() . "', 0, '" . gmdate($GLOBALS['timedate']->get_db_date_time_format(), strtotime('now')) . "', '" . gmdate($GLOBALS['timedate']->get_db_date_time_format(), strtotime('now')) . "', '" . $current_user->id . "', '" . $current_user->id . "', 'DST Fix', '3.5.1b', '3.5.1b')";
    $qRes = $db->query($qDst);
    // record server's time zone locale for future upgrades
    $qSTZ = "INSERT INTO config VALUES ('Update', 'server_timezone', '" . $_REQUEST['server_timezone'] . "')";
    $rSTZ = $db->query($qSTZ);
    if (empty($_REQUEST['confirmed']) || $_REQUEST['confirmed'] == 'false') {
        $display = $mod_strings['LBL_DST_FIX_DONE_DESC'];