smart_date_time: properly support local TZ; use user-defined date formats
This commit is contained in:
parent
5c7c7da9e1
commit
2a5c136e96
|
@ -2137,7 +2137,8 @@
|
||||||
$user_timestamp = $dt->format('U') + $user_tz->getOffset($dt);
|
$user_timestamp = $dt->format('U') + $user_tz->getOffset($dt);
|
||||||
|
|
||||||
if (!$no_smart_dt && get_pref($link, 'HEADLINES_SMART_DATE', $owner_uid)) {
|
if (!$no_smart_dt && get_pref($link, 'HEADLINES_SMART_DATE', $owner_uid)) {
|
||||||
return smart_date_time($user_timestamp);
|
return smart_date_time($link, $user_timestamp,
|
||||||
|
$user_tz->getOffset($dt), $owner_uid);
|
||||||
} else {
|
} else {
|
||||||
if ($long)
|
if ($long)
|
||||||
$format = get_pref($link, 'LONG_DATE_FORMAT', $owner_uid);
|
$format = get_pref($link, 'LONG_DATE_FORMAT', $owner_uid);
|
||||||
|
@ -2148,13 +2149,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function smart_date_time($timestamp) {
|
function smart_date_time($link, $timestamp, $tz_offset = 0, $owner_uid = false) {
|
||||||
if (date("Y.m.d", $timestamp) == date("Y.m.d")) {
|
if (!$owner_uid) $owner_uid = $_SESSION['uid'];
|
||||||
|
|
||||||
|
if (date("Y.m.d", $timestamp) == date("Y.m.d", time() + $tz_offset)) {
|
||||||
return date("G:i", $timestamp);
|
return date("G:i", $timestamp);
|
||||||
} else if (date("Y", $timestamp) == date("Y")) {
|
} else if (date("Y", $timestamp) == date("Y", time() + $tz_offset)) {
|
||||||
return date("M d, G:i", $timestamp);
|
$format = get_pref($link, 'SHORT_DATE_FORMAT', $owner_uid);
|
||||||
|
return date($format, $timestamp);
|
||||||
} else {
|
} else {
|
||||||
return date("Y/m/d, G:i", $timestamp);
|
$format = get_pref($link, 'LONG_DATE_FORMAT', $owner_uid);
|
||||||
|
return date($format, $timestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue