Add Temporal::utc() shorthand to Temporal::convert()
This commit is contained in:
parent
ca8209a2ce
commit
35d06bd9eb
22 changed files with 173 additions and 128 deletions
|
@ -111,7 +111,7 @@ function api_source()
|
|||
function api_date($str)
|
||||
{
|
||||
// Wed May 23 06:01:13 +0000 2007
|
||||
return Temporal::convert($str, 'UTC', 'UTC', "D M d H:i:s +0000 Y");
|
||||
return Temporal::utc($str, "D M d H:i:s +0000 Y");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3207,7 +3207,7 @@ function api_account_rate_limit_status($type)
|
|||
'@attributes' => ["type" => "integer"],
|
||||
'hourly-limit' => '150',
|
||||
'@attributes2' => ["type" => "integer"],
|
||||
'reset-time' => Temporal::convert('now + 1 hour', 'UTC', 'UTC', Temporal::ATOM),
|
||||
'reset-time' => Temporal::utc('now + 1 hour', Temporal::ATOM),
|
||||
'@attributes3' => ["type" => "datetime"],
|
||||
'reset_time_in_seconds' => strtotime('now + 1 hour'),
|
||||
'@attributes4' => ["type" => "integer"],
|
||||
|
@ -3217,7 +3217,7 @@ function api_account_rate_limit_status($type)
|
|||
'reset_time_in_seconds' => strtotime('now + 1 hour'),
|
||||
'remaining_hits' => '150',
|
||||
'hourly_limit' => '150',
|
||||
'reset_time' => api_date(Temporal::convert('now + 1 hour', 'UTC', 'UTC', Temporal::ATOM)),
|
||||
'reset_time' => api_date(Temporal::utc('now + 1 hour', Temporal::ATOM)),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -245,17 +245,17 @@ function format_event_diaspora($ev) {
|
|||
|
||||
// @todo What. Is. Going. On. With. This. Useless. Ternary. Operator? - mrpetovan
|
||||
$o .= L10n::t('Starts:') . ' ' . '['
|
||||
. (($ev['adjust']) ? day_translate(Temporal::convert($ev['start'], 'UTC', 'UTC', $bd_format))
|
||||
: day_translate(Temporal::convert($ev['start'], 'UTC', 'UTC', $bd_format))
|
||||
. (($ev['adjust']) ? day_translate(Temporal::utc($ev['start'], $bd_format))
|
||||
: day_translate(Temporal::convert($ev['start'], $bd_format))
|
||||
)
|
||||
. '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::convert($ev['start'])) . ")\n";
|
||||
. '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::utc($ev['start'])) . ")\n";
|
||||
|
||||
if (! $ev['nofinish']) {
|
||||
$o .= L10n::t('Finishes:') . ' ' . '['
|
||||
. (($ev['adjust']) ? day_translate(Temporal::convert($ev['finish'], 'UTC', 'UTC', $bd_format))
|
||||
: day_translate(Temporal::convert($ev['finish'], 'UTC', 'UTC', $bd_format))
|
||||
. (($ev['adjust']) ? day_translate(Temporal::utc($ev['finish'], $bd_format))
|
||||
: day_translate(Temporal::utc($ev['finish'], $bd_format))
|
||||
)
|
||||
. '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::convert($ev['finish'])) . ")\n";
|
||||
. '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::utc($ev['finish'])) . ")\n";
|
||||
}
|
||||
|
||||
if (strlen($ev['location'])) {
|
||||
|
|
|
@ -26,13 +26,17 @@ function format_event_html($ev, $simple = false) {
|
|||
|
||||
$bd_format = L10n::t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM.
|
||||
|
||||
$event_start = (($ev['adjust']) ?
|
||||
day_translate(Temporal::convert($ev['start'], date_default_timezone_get(), 'UTC', $bd_format))
|
||||
: day_translate(Temporal::convert($ev['start'], 'UTC', 'UTC', $bd_format)));
|
||||
$event_start = day_translate(
|
||||
$ev['adjust'] ?
|
||||
Temporal::convert($ev['start'], date_default_timezone_get(), 'UTC', $bd_format)
|
||||
: Temporal::utc($ev['start'], $bd_format)
|
||||
);
|
||||
|
||||
$event_end = (($ev['adjust']) ?
|
||||
day_translate(Temporal::convert($ev['finish'] , date_default_timezone_get(), 'UTC', $bd_format ))
|
||||
: day_translate(Temporal::convert($ev['finish'] , 'UTC', 'UTC', $bd_format )));
|
||||
$event_end = day_translate(
|
||||
$ev['adjust'] ?
|
||||
Temporal::convert($ev['finish'], date_default_timezone_get(), 'UTC', $bd_format)
|
||||
: Temporal::utc($ev['finish'], $bd_format)
|
||||
);
|
||||
|
||||
if ($simple) {
|
||||
$o = "<h3>" . bbcode($ev['summary']) . "</h3>";
|
||||
|
@ -57,13 +61,13 @@ function format_event_html($ev, $simple = false) {
|
|||
$o .= '<div class="summary event-summary">' . bbcode($ev['summary']) . '</div>' . "\r\n";
|
||||
|
||||
$o .= '<div class="event-start"><span class="event-label">' . L10n::t('Starts:') . '</span> <span class="dtstart" title="'
|
||||
. Temporal::convert($ev['start'], 'UTC', 'UTC', (($ev['adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s' ))
|
||||
. Temporal::utc($ev['start'], (($ev['adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s' ))
|
||||
. '" >'.$event_start
|
||||
. '</span></div>' . "\r\n";
|
||||
|
||||
if (! $ev['nofinish']) {
|
||||
$o .= '<div class="event-end" ><span class="event-label">' . L10n::t('Finishes:') . '</span> <span class="dtend" title="'
|
||||
. Temporal::convert($ev['finish'], 'UTC', 'UTC', (($ev['adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s' ))
|
||||
. Temporal::utc($ev['finish'], (($ev['adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s' ))
|
||||
. '" >'.$event_end
|
||||
. '</span></div>' . "\r\n";
|
||||
}
|
||||
|
@ -591,15 +595,15 @@ function process_events($arr) {
|
|||
$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::convert($rr['start'], 'UTC', 'UTC', 'j'));
|
||||
$d = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', $fmt) : Temporal::convert($rr['start'], 'UTC', 'UTC', $fmt));
|
||||
$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));
|
||||
$d = day_translate($d);
|
||||
|
||||
$start = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'c') : Temporal::convert($rr['start'], 'UTC', 'UTC', 'c'));
|
||||
$start = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', '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::convert($rr['finish'], 'UTC', 'UTC', 'c'));
|
||||
$end = (($rr['adjust']) ? Temporal::convert($rr['finish'], date_default_timezone_get(), 'UTC', 'c') : Temporal::utc($rr['finish'], 'c'));
|
||||
}
|
||||
|
||||
$is_first = ($d !== $last_date);
|
||||
|
@ -924,22 +928,48 @@ function format_event_item($item) {
|
|||
$tformat = L10n::t('g:i A'); // 8:01 AM.
|
||||
|
||||
// Convert the time to different formats.
|
||||
$dtstart_dt = (($item['event-adjust']) ? day_translate(Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $dformat)) : day_translate(Temporal::convert($item['event-start'], 'UTC', 'UTC', $dformat)));
|
||||
$dtstart_title = Temporal::convert($item['event-start'], 'UTC', 'UTC', (($item['event-adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s'));
|
||||
$dtstart_dt = day_translate(
|
||||
$item['event-adjust'] ?
|
||||
Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $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 = (($item['event-adjust']) ? day_short_translate(Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', 'M')) : day_short_translate(Temporal::convert($item['event-start'], 'UTC', 'UTC', 'M')));
|
||||
$month_short = day_short_translate(
|
||||
$item['event-adjust'] ?
|
||||
Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', '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::convert($item['event-start'], 'UTC', 'UTC', 'j'));
|
||||
$start_time = (($item['event-adjust']) ? Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $tformat) : Temporal::convert($item['event-start'], 'UTC', 'UTC', $tformat));
|
||||
$start_short = (($item['event-adjust']) ? day_short_translate(Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $dformat_short)) : day_short_translate(Temporal::convert($item['event-start'], 'UTC', 'UTC', $dformat_short)));
|
||||
$date_short = $item['event-adjust'] ?
|
||||
Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', 'j')
|
||||
: Temporal::utc($item['event-start'], 'j');
|
||||
$start_time = $item['event-adjust'] ?
|
||||
Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $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::utc($item['event-start'], $dformat_short)
|
||||
);
|
||||
|
||||
// If the option 'nofinisch' isn't set, we need to format the finish date/time.
|
||||
if (!$item['event-nofinish']) {
|
||||
$finish = true;
|
||||
$dtend_dt = (($item['event-adjust']) ? day_translate(Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat)) : day_translate(Temporal::convert($item['event-finish'], 'UTC', 'UTC', $dformat)));
|
||||
$dtend_title = Temporal::convert($item['event-finish'], 'UTC', 'UTC', (($item['event-adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s'));
|
||||
$end_short = (($item['event-adjust']) ? day_short_translate(Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat_short)) : day_short_translate(Temporal::convert($item['event-finish'], 'UTC', 'UTC', $dformat_short)));
|
||||
$end_time = (($item['event-adjust']) ? Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $tformat) : Temporal::convert($item['event-finish'], 'UTC', 'UTC', $tformat));
|
||||
$dtend_dt = day_translate(
|
||||
$item['event-adjust'] ?
|
||||
Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $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::utc($item['event-finish'], $dformat_short)
|
||||
);
|
||||
$end_time = $item['event-adjust'] ?
|
||||
Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $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)) {
|
||||
$same_date = true;
|
||||
|
|
|
@ -437,14 +437,14 @@ function list_post_dates($uid, $wall) {
|
|||
$dyear = intval(substr($dnow, 0, 4));
|
||||
$dstart = substr($dnow, 0, 8) . '01';
|
||||
$dend = substr($dnow, 0, 8) . get_dim(intval($dnow), intval(substr($dnow, 5)));
|
||||
$start_month = Temporal::convert($dstart, 'UTC', 'UTC', 'Y-m-d');
|
||||
$end_month = Temporal::convert($dend, 'UTC', 'UTC', 'Y-m-d');
|
||||
$str = day_translate(Temporal::convert($dnow, 'UTC', 'UTC', 'F'));
|
||||
$start_month = Temporal::utc($dstart, 'Y-m-d');
|
||||
$end_month = Temporal::utc($dend, 'Y-m-d');
|
||||
$str = day_translate(Temporal::utc($dnow, 'F'));
|
||||
if (!$ret[$dyear]) {
|
||||
$ret[$dyear] = [];
|
||||
}
|
||||
$ret[$dyear][] = [$str, $end_month, $start_month];
|
||||
$dnow = Temporal::convert($dnow . ' -1 month', 'UTC', 'UTC', 'Y-m-d');
|
||||
$dnow = Temporal::utc($dnow . ' -1 month', 'Y-m-d');
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue