better timezone handling
This commit is contained in:
parent
d9824cda40
commit
ffb7933bda
|
@ -1283,6 +1283,16 @@ function getTimeZone() {
|
|||
return new DateTimeZone($timeZone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current time in formatted form.
|
||||
*
|
||||
* @param unknown $format format to use (e.g. 'Y-m-d H:i:s,00')
|
||||
*/
|
||||
function getFormattedTime($format) {
|
||||
$time = new DateTime(null, getTimeZone());
|
||||
return $time->format($format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a number of seconds to a more human readable format with minutes, hours, etc.
|
||||
* E.g. 70 seconds will return 1m10s.
|
||||
|
|
|
@ -123,7 +123,7 @@ class lamPDF extends UFPDF {
|
|||
$this->Line(10,282,200,282);
|
||||
$this->SetY(286);
|
||||
$this->SetFont($this->fontName,"",7);
|
||||
$this->Cell(0,5,_("This document was automatically created by LDAP Account Manager") . ' (' . date('Y-m-d H:i:s T') . ')',0,0,"C",0);
|
||||
$this->Cell(0,5,_("This document was automatically created by LDAP Account Manager") . ' (' . getFormattedTime('Y-m-d H:i:s T') . ')',0,0,"C",0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -551,7 +551,7 @@ class pykotaUser extends baseModule {
|
|||
$errors[] = $this->messages['pykotaPayments'][0];
|
||||
}
|
||||
else {
|
||||
$this->attributes['pykotaPayments'][] = date('Y-m-d H:i:s,00', time()) . ' # ' . $amount . ' # ' . $comment;
|
||||
$this->attributes['pykotaPayments'][] = getFormattedTime('Y-m-d H:i:s,00') . ' # ' . $amount . ' # ' . $comment;
|
||||
// new balance
|
||||
$newBalance = 0.0;
|
||||
if (!empty($this->attributes['pykotaBalance'][0])) {
|
||||
|
@ -754,7 +754,7 @@ class pykotaUser extends baseModule {
|
|||
}
|
||||
$this->attributes['pykotaBalance'][0] = $amount;
|
||||
$this->attributes['pykotaLifeTimePaid'][0] = $amount;
|
||||
$this->attributes['pykotaPayments'][] = date('Y-m-d H:i:s,00', time()) . ' # ' . $amount . ' # ';
|
||||
$this->attributes['pykotaPayments'][] = getFormattedTime('Y-m-d H:i:s,00') . ' # ' . $amount . ' # ';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -873,7 +873,7 @@ class pykotaUser extends baseModule {
|
|||
if (!empty($rawAccounts[$i][$ids['pykotaUser_pykotaBalanceComment']])) {
|
||||
$comment = base64_encode($rawAccounts[$i][$ids['pykotaUser_pykotaBalanceComment']]);
|
||||
}
|
||||
$partialAccounts[$i]['pykotaPayments'][0] = date('Y-m-d H:i:s,00', time()) . ' # ' . $balance . ' # ' . $comment;
|
||||
$partialAccounts[$i]['pykotaPayments'][0] = getFormattedTime('Y-m-d H:i:s,00') . ' # ' . $balance . ' # ' . $comment;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1133,7 +1133,8 @@ class sambaSamAccount extends baseModule implements passwordService {
|
|||
if (!$this->isBooleanConfigOptionSet('sambaSamAccount_hideSambaPwdLastSet')) {
|
||||
$sambaPwdLastSet = '';
|
||||
if (!empty($this->attributes['sambaPwdLastSet'][0])) {
|
||||
$sambaPwdLastSet = date('d.m.Y H:i', $this->attributes['sambaPwdLastSet'][0]);
|
||||
$time = new DateTime('@' . $this->attributes['sambaPwdLastSet'][0], getTimeZone());
|
||||
$sambaPwdLastSet = $time->format('d.m.Y H:i');
|
||||
}
|
||||
$return->addElement(new htmlOutputText(_('Last password change')));
|
||||
$return->addElement(new htmlOutputText($sambaPwdLastSet));
|
||||
|
@ -2251,7 +2252,8 @@ class sambaSamAccount extends baseModule implements passwordService {
|
|||
if (in_array('sambaPwdLastSet', $fields)) {
|
||||
$sambaPwdLastSet = '';
|
||||
if (isset($attributes['sambaPwdLastSet'][0])) {
|
||||
$sambaPwdLastSet = date('d.m.Y H:i', $attributes['sambaPwdLastSet'][0]);
|
||||
$time = new DateTime('@' . $attributes['sambaPwdLastSet'][0], getTimeZone());
|
||||
$sambaPwdLastSet = $time->format('d.m.Y H:i');
|
||||
}
|
||||
$row = new htmlResponsiveRow();
|
||||
$row->addLabel(new htmlOutputText($this->getSelfServiceLabel('sambaPwdLastSet', _('Last password change'))));
|
||||
|
@ -2434,8 +2436,9 @@ class sambaSamAccount extends baseModule implements passwordService {
|
|||
if (!isset($domains[$i]->maxPwdAge) || ($domains[$i]->maxPwdAge < 0)) {
|
||||
return $return;
|
||||
}
|
||||
$time = $this->attributes['sambaPwdLastSet'][0] + $domains[$i]->maxPwdAge;
|
||||
return date('d.m.Y H:i', $time);
|
||||
$timeVal = $this->attributes['sambaPwdLastSet'][0] + $domains[$i]->maxPwdAge;
|
||||
$time = new DateTime('@' . $timeVal, getTimeZone());
|
||||
return $time->format('d.m.Y H:i');
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
|
@ -2462,8 +2465,9 @@ class sambaSamAccount extends baseModule implements passwordService {
|
|||
if (!isset($domains[$i]->minPwdAge) || ($domains[$i]->minPwdAge < 0)) {
|
||||
return $return;
|
||||
}
|
||||
$time = $this->attributes['sambaPwdLastSet'][0] + $domains[$i]->minPwdAge;
|
||||
return date('d.m.Y H:i', $time);
|
||||
$timeVal = $this->attributes['sambaPwdLastSet'][0] + $domains[$i]->minPwdAge;
|
||||
$time = new DateTime('@' . $timeVal, getTimeZone());
|
||||
return $time->format('d.m.Y H:i');
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
|
|
|
@ -167,7 +167,7 @@ class shadowAccount extends baseModule implements passwordService {
|
|||
'shadowLastChange' => _('Last password change'),
|
||||
'shadowWarning' => _('Password warning'),
|
||||
'shadowInactive' => _('Account inactive'),
|
||||
'shadowExpire' => _('Password expiration'),
|
||||
'shadowExpire' => _('Account expiration date'),
|
||||
'shadowMinAge' => _('Minimum password age'),
|
||||
'shadowMaxAge' => _('Maximum password age'),
|
||||
);
|
||||
|
@ -542,13 +542,16 @@ class shadowAccount extends baseModule implements passwordService {
|
|||
* @return list of PDF entries (array(<PDF key> => <PDF lines>))
|
||||
*/
|
||||
function get_pdfEntries($pdfKeys) {
|
||||
$timeZone = new DateTimeZone($_SESSION['config']->getTimeZone());
|
||||
$shadowLastChange = '';
|
||||
if (isset($this->attributes['shadowLastChange'][0])) {
|
||||
$shadowLastChange = date('d. m. Y',$this->attributes['shadowLastChange'][0]*24*3600);
|
||||
if (!empty($this->attributes['shadowLastChange'][0])) {
|
||||
$time = new DateTime('@' . $this->attributes['shadowLastChange'][0]*24*3600, $timeZone);
|
||||
$shadowLastChange = $time->format('d. m. Y');
|
||||
}
|
||||
$shadowExpire = '';
|
||||
if (isset($this->attributes['shadowExpire'][0])) {
|
||||
$shadowExpire = date('d. m. Y',$this->attributes['shadowExpire'][0]*24*3600);
|
||||
if (!empty($this->attributes['shadowExpire'][0])) {
|
||||
$time = new DateTime('@' . $this->attributes['shadowExpire'][0]*24*3600);
|
||||
$shadowExpire = $time->format('d. m. Y');
|
||||
}
|
||||
$return = array();
|
||||
$this->addPDFKeyValue($return, 'shadowLastChange', _('Last password change'), $shadowLastChange);
|
||||
|
|
|
@ -646,12 +646,13 @@ class lamUserList extends lamList {
|
|||
}
|
||||
// expire dates
|
||||
elseif ($attribute == 'shadowexpire') {
|
||||
if (isset($entry[$attribute][0]) && ($entry[$attribute][0] != '')) {
|
||||
echo date('d. m. Y', $entry[$attribute][0] * 24 * 3600);
|
||||
if (!empty($entry[$attribute][0])) {
|
||||
$time = new DateTime('@' . $entry[$attribute][0] * 24 * 3600, new DateTimeZone($_SESSION['config']->getTimeZone()));
|
||||
echo $time->format('d.m.Y');
|
||||
}
|
||||
}
|
||||
elseif ($attribute == 'sambakickofftime') {
|
||||
if (isset($entry[$attribute][0]) && ($entry[$attribute][0] != '')) {
|
||||
if (!empty($entry[$attribute][0])) {
|
||||
if ($entry[$attribute][0] > 2147483648) {
|
||||
echo "∞";
|
||||
}
|
||||
|
|
|
@ -486,7 +486,13 @@ parseHtml(null, $globalFieldset, array(), false, $tabindex, 'user');
|
|||
function formatSSLTimestamp($time) {
|
||||
$matches = array();
|
||||
if (!empty($time)) {
|
||||
return date('d.m.Y', $time);
|
||||
$timeZone = 'UTC';
|
||||
$sysTimeZone = @date_default_timezone_get();
|
||||
if (!empty($sysTimeZone)) {
|
||||
$timeZone = $sysTimeZone;
|
||||
}
|
||||
$date = new DateTime('@' . $time, new DateTimeZone($timeZone));
|
||||
return $date->format('d.m.Y');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue