X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FEvent%2Feventlistitem.php;h=fb27704461378cc788c47a2754a7c572c7829574;hb=14f03a237e1a67a764a75cfa8e6fed34f0074a4b;hp=3d2d3ecd8f0276748ec90f397b20abe5e946102b;hpb=1ab8004d7873aadfba0fe7b5d6c206738bf769fc;p=quix0rs-gnu-social.git diff --git a/plugins/Event/eventlistitem.php b/plugins/Event/eventlistitem.php index 3d2d3ecd8f..fb27704461 100644 --- a/plugins/Event/eventlistitem.php +++ b/plugins/Event/eventlistitem.php @@ -4,7 +4,7 @@ * Copyright (C) 2011, StatusNet, Inc. * * Notice-list representation of an event - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class EventListItem extends NoticeListItemAdapter { function showNotice() @@ -55,13 +54,17 @@ class EventListItem extends NoticeListItemAdapter $this->nli->out->elementEnd('div'); } - function showEventNotice($notice, $out) + function showContent() { + $notice = $this->nli->notice; + $out = $this->nli->out; + $profile = $notice->getProfile(); $event = Happening::fromNotice($notice); if (empty($event)) { - $out->element('p', null, _('Deleted.')); + // TRANS: Content for a deleted RSVP list item (RSVP stands for "please respond"). + $out->element('p', null, _m('Deleted.')); return; } @@ -80,13 +83,33 @@ class EventListItem extends NoticeListItemAdapter $out->elementEnd('h3'); // VEVENT/H3 OUT - $startDate = strftime("%x", strtotime($event->start_time)); - $startTime = strftime("%R", strtotime($event->start_time)); + $now = new DateTime(); + $startDate = new DateTime($event->start_time); + $endDate = new DateTime($event->end_time); + $userTz = new DateTimeZone(common_timezone()); + + // Localize the time for the observer + $now->setTimeZone($userTz); + $startDate->setTimezone($userTz); + $endDate->setTimezone($userTz); + + $thisYear = $now->format('Y'); + $startYear = $startDate->format('Y'); + $endYear = $endDate->format('Y'); + + $dateFmt = 'D, F j, '; // e.g.: Mon, Aug 31 + + if ($startYear != $thisYear || $endYear != $thisYear) { + $dateFmt .= 'Y,'; // append year if we need to think about years + } + + $startDateStr = $startDate->format($dateFmt); + $endDateStr = $endDate->format($dateFmt); - $endDate = strftime("%x", strtotime($event->end_time)); - $endTime = strftime("%R", strtotime($event->end_time)); + $timeFmt = 'g:ia'; - // FIXME: better dates + $startTimeStr = $startDate->format($timeFmt); + $endTimeStr = $endDate->format("{$timeFmt} (T)"); $out->elementStart('div', 'event-times'); // VEVENT/EVENT-TIMES IN @@ -95,16 +118,16 @@ class EventListItem extends NoticeListItemAdapter $out->element('abbr', array('class' => 'dtstart', 'title' => common_date_iso8601($event->start_time)), - $startDate . ' ' . $startTime); - $out->text(' - '); - if ($startDate == $endDate) { + $startDateStr . ' ' . $startTimeStr); + $out->text(' – '); + if ($startDateStr == $endDateStr) { $out->element('span', array('class' => 'dtend', 'title' => common_date_iso8601($event->end_time)), - $endTime); + $endTimeStr); } else { $out->element('span', array('class' => 'dtend', 'title' => common_date_iso8601($event->end_time)), - $endDate . ' ' . $endTime); + $endDateStr . ' ' . $endTimeStr); } $out->elementEnd('div'); // VEVENT/EVENT-TIMES OUT @@ -132,7 +155,7 @@ class EventListItem extends NoticeListItemAdapter $out->element('strong', null, _m('Attending:')); $out->element('span', 'event-rsvps', // TRANS: RSVP counts. - // TRANS: %1$d, %2$d and %3$d are numbers of RSVPs. + // TRANS: %1$d, %2$d and %3$d are numbers of RSVPs. sprintf(_m('Yes: %1$d No: %2$d Maybe: %3$d'), count($rsvps[RSVP::POSITIVE]), count($rsvps[RSVP::NEGATIVE]),