'categories' => $categories,
'folders' => $folders,
'text' => strip_tags($body_e),
- 'localtime' => Temporal::convert($item['created'], date_default_timezone_get(), 'UTC', 'r'),
+ 'localtime' => Temporal::local($item['created'], 'r'),
'ago' => (($item['app']) ? L10n::t('%s from %s', relative_date($item['created']),$item['app']) : relative_date($item['created'])),
'location' => $location_e,
'indent' => '',
$event_start = day_translate(
$ev['adjust'] ?
- Temporal::convert($ev['start'], date_default_timezone_get(), 'UTC', $bd_format)
+ Temporal::local($ev['start'], $bd_format)
: Temporal::utc($ev['start'], $bd_format)
);
$event_end = day_translate(
$ev['adjust'] ?
- Temporal::convert($ev['finish'], date_default_timezone_get(), 'UTC', $bd_format)
+ Temporal::local($ev['finish'], $bd_format)
: Temporal::utc($ev['finish'], $bd_format)
);
function ev_compare($a,$b) {
- $date_a = (($a['adjust']) ? Temporal::convert($a['start'], date_default_timezone_get()) : $a['start']);
- $date_b = (($b['adjust']) ? Temporal::convert($b['start'], date_default_timezone_get()) : $b['start']);
+ $date_a = (($a['adjust']) ? Temporal::local($a['start']) : $a['start']);
+ $date_b = (($b['adjust']) ? Temporal::local($b['start']) : $b['start']);
if ($date_a === $date_b) {
return strcasecmp($a['desc'], $b['desc']);
$fmt = L10n::t('l, F j');
if (count($arr)) {
foreach ($arr as $rr) {
- $j = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::utc($rr['start'], 'j'));
- $d = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', $fmt) : Temporal::utc($rr['start'], $fmt));
+ $j = (($rr['adjust']) ? Temporal::local($rr['start'], 'j') : Temporal::utc($rr['start'], 'j'));
+ $d = (($rr['adjust']) ? Temporal::local($rr['start'], $fmt) : Temporal::utc($rr['start'], $fmt));
$d = day_translate($d);
- $start = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'c') : Temporal::utc($rr['start'], 'c'));
+ $start = (($rr['adjust']) ? Temporal::local($rr['start'], 'c') : Temporal::utc($rr['start'], 'c'));
if ($rr['nofinish']) {
$end = null;
} else {
- $end = (($rr['adjust']) ? Temporal::convert($rr['finish'], date_default_timezone_get(), 'UTC', 'c') : Temporal::utc($rr['finish'], 'c'));
+ $end = (($rr['adjust']) ? Temporal::local($rr['finish'], 'c') : Temporal::utc($rr['finish'], 'c'));
}
$is_first = ($d !== $last_date);
// Convert the time to different formats.
$dtstart_dt = day_translate(
$item['event-adjust'] ?
- Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $dformat)
+ Temporal::local($item['event-start'], $dformat)
: Temporal::utc($item['event-start'], $dformat)
);
$dtstart_title = Temporal::utc($item['event-start'], $item['event-adjust'] ? Temporal::ATOM : 'Y-m-d\TH:i:s');
// Format: Jan till Dec.
$month_short = day_short_translate(
$item['event-adjust'] ?
- Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', 'M')
+ Temporal::local($item['event-start'], 'M')
: Temporal::utc($item['event-start'], 'M')
);
// Format: 1 till 31.
$date_short = $item['event-adjust'] ?
- Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', 'j')
+ Temporal::local($item['event-start'], 'j')
: Temporal::utc($item['event-start'], 'j');
$start_time = $item['event-adjust'] ?
- Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $tformat)
+ Temporal::local($item['event-start'], $tformat)
: Temporal::utc($item['event-start'], $tformat);
$start_short = day_short_translate(
$item['event-adjust'] ?
- Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $dformat_short)
+ Temporal::local($item['event-start'], $dformat_short)
: Temporal::utc($item['event-start'], $dformat_short)
);
$finish = true;
$dtend_dt = day_translate(
$item['event-adjust'] ?
- Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat)
+ Temporal::local($item['event-finish'], $dformat)
: Temporal::utc($item['event-finish'], $dformat)
);
$dtend_title = Temporal::utc($item['event-finish'], $item['event-adjust'] ? Temporal::ATOM : 'Y-m-d\TH:i:s');
$end_short = day_short_translate(
$item['event-adjust'] ?
- Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat_short)
+ Temporal::local($item['event-finish'], $dformat_short)
: Temporal::utc($item['event-finish'], $dformat_short)
);
$end_time = $item['event-adjust'] ?
- Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $tformat)
+ Temporal::local($item['event-finish'], $tformat)
: Temporal::utc($item['event-finish'], $tformat);
// Check if start and finish time is at the same day.
if (substr($dtstart_title, 0, 10) === substr($dtend_title, 0, 10)) {
$start = Temporal::utc($start);
$finish = Temporal::utc($finish);
- $adjust_start = Temporal::convert($start, date_default_timezone_get());
- $adjust_finish = Temporal::convert($finish, date_default_timezone_get());
+ $adjust_start = Temporal::local($start);
+ $adjust_finish = Temporal::local($finish);
// put the event parametes in an array so we can better transmit them
$event_params = [
if (DBM::is_result($r)) {
$r = sort_by_date($r);
foreach ($r as $rr) {
- $j = $rr['adjust'] ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::utc($rr['start'], 'j');
+ $j = $rr['adjust'] ? Temporal::local($rr['start'], 'j') : Temporal::utc($rr['start'], 'j');
if (!x($links, $j)) {
$links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j;
}
$insecure = L10n::t('Private communications are not available for this contact.');
- $last_update = (($contact['last-update'] <= NULL_DATE) ? L10n::t('Never') : Temporal::convert($contact['last-update'], date_default_timezone_get(), 'UTC', 'D, j M Y, g:i A'));
+ $last_update = (($contact['last-update'] <= NULL_DATE) ? L10n::t('Never') : Temporal::local($contact['last-update'], 'D, j M Y, g:i A'));
if ($contact['last-update'] > NULL_DATE) {
$last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? L10n::t("\x28Update was successful\x29") : L10n::t("\x28Update was not successful\x29"));
$start = Temporal::utc($start);
$finish = Temporal::utc($finish);
- $adjust_start = Temporal::convert($start, date_default_timezone_get());
- $adjust_finish = Temporal::convert($finish, date_default_timezone_get());
+ $adjust_start = Temporal::local($start);
+ $adjust_finish = Temporal::local($finish);
// put the event parametes in an array so we can better transmit them
$event_params = [
if (DBM::is_result($r)) {
$r = sort_by_date($r);
foreach ($r as $rr) {
- $j = $rr['adjust'] ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::utc($rr['start'], 'j');
+ $j = $rr['adjust'] ? Temporal::local($rr['start'], 'j') : Temporal::utc($rr['start'], 'j');
if (! x($links,$j)) {
$links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j;
}
'body' => $body_e,
'delete' => L10n::t('Delete message'),
'to_name' => $to_name_e,
- 'date' => Temporal::convert($message['created'], date_default_timezone_get(), 'UTC', 'D, d M Y - g:i A'),
+ 'date' => Temporal::local($message['created'], 'D, d M Y - g:i A'),
'ago' => relative_date($message['created']),
];
'$delete' => L10n::t('Delete conversation'),
'$body' => $body_e,
'$to_name' => $to_name_e,
- '$date' => Temporal::convert($rr['mailcreated'], date_default_timezone_get(), 'UTC', L10n::t('D, d M Y - g:i A')),
+ '$date' => Temporal::local($rr['mailcreated'], L10n::t('D, d M Y - g:i A')),
'$ago' => relative_date($rr['mailcreated']),
'$seen' => $rr['mailseen'],
'$count' => L10n::tt('%d message', '%d messages', $rr['count']),
$notif['photo'] = proxy_url($notif['photo'], false, PROXY_SIZE_MICRO);
}
- $local_time = Temporal::convert($notif['date'], date_default_timezone_get());
+ $local_time = Temporal::local($notif['date']);
$notifications[] = [
'id' => $notif['id'],
'$gender' => ContactSelector::gender($r[0]['gender']),
'$marital' => ContactSelector::maritalStatus($r[0]['marital']),
'$with' => ['with', L10n::t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), L10n::t('Examples: cathy123, Cathy Williams, cathy@example.com')],
- '$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : Temporal::convert($r[0]['howlong'], date_default_timezone_get()))],
+ '$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : Temporal::local($r[0]['howlong']))],
'$sexual' => ContactSelector::sexualPreference($r[0]['sexual']),
'$about' => ['about', L10n::t('Tell us about yourself...'), $r[0]['about']],
'$xmpp' => ['xmpp', L10n::t("XMPP \x28Jabber\x29 address:"), $r[0]['xmpp'], L10n::t("The XMPP address will be propagated to your contacts so that they can follow you.")],
{
$rets = [];
foreach ($notes as $n) {
- $local_time = Temporal::convert($n['date'], date_default_timezone_get());
+ $local_time = Temporal::local($n['date']);
$n['timestamp'] = strtotime($local_time);
$n['date_rel'] = relative_date($n['date']);
$n['msg_html'] = bbcode($n['msg'], false, false, false, false);
$default_item_image = proxy_url($it['photo'], false, PROXY_SIZE_MICRO);
$default_item_url = $it['url'];
$default_item_text = strip_tags(bbcode($it['msg']));
- $default_item_when = Temporal::convert($it['date'], date_default_timezone_get(), 'UTC', 'r');
+ $default_item_when = Temporal::local($it['date'], 'r');
$default_item_ago = relative_date($it['date']);
break;
$default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
$default_item_url = $it['author-link'];
$default_item_text = L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']);
- $default_item_when = Temporal::convert($it['created'], date_default_timezone_get(), 'UTC', 'r');
+ $default_item_when = Temporal::local($it['created'], 'r');
$default_item_ago = relative_date($it['created']);
break;
$default_item_text = (($it['id'] == $it['parent'])
? L10n::t("%s created a new post", $it['author-name'])
: L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']));
- $default_item_when = Temporal::convert($it['created'], date_default_timezone_get(), 'UTC', 'r');
+ $default_item_when = Temporal::local($it['created'], 'r');
$default_item_ago = relative_date($it['created']);
}
if (strtotime($item['edited']) - strtotime($item['created']) > 1) {
$edited = [
'label' => L10n::t('This entry was edited'),
- 'date' => Temporal::convert($item['edited'], date_default_timezone_get(), 'UTC', 'r'),
+ 'date' => Temporal::local($item['edited'], 'r'),
'relative' => relative_date($item['edited'])
];
}
'osparkle' => $osparkle,
'sparkle' => $sparkle,
'title' => $title_e,
- 'localtime' => Temporal::convert($item['created'], date_default_timezone_get(), 'UTC', 'r'),
+ 'localtime' => Temporal::local($item['created'], 'r'),
'ago' => $item['app'] ? L10n::t('%s from %s', relative_date($item['created']), $item['app']) : relative_date($item['created']),
'app' => $item['app'],
'created' => relative_date($item['created']),
return self::convert($time, 'UTC', 'UTC', $format);
}
+ /**
+ * convert() shorthand for local.
+ *
+ * @param string $time A date/time string
+ * @param string $format DateTime format string or Temporal constant
+ * @return string
+ */
+ public static function local($time, $format = self::MYSQL)
+ {
+ return self::convert($time, date_default_timezone_get(), 'UTC', $format);
+ }
+
/**
* convert() shorthand for timezoned now.
*
*/
public static function localNow($format = self::MYSQL)
{
- return self::convert('now', date_default_timezone_get(), 'UTC', $format);
+ return self::local('now', $format);
}
/**
*/
public static function utcNow($format = self::MYSQL)
{
- return self::convert('now', 'UTC', 'UTC', $format);
+ return self::utc('now', $format);
}
/**