diff options
author | Mario Vavti <mario@mariovavti.com> | 2019-05-26 18:05:11 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2019-05-26 18:05:11 +0200 |
commit | e466d72058b2543bec69c77d2730828acada38a1 (patch) | |
tree | aeb1a73e02c3d28409e96eb0591a7e28846b5539 /include/event.php | |
parent | 528b9b6a60d847b0ecb639cb7fb8e01ee79b11d4 (diff) | |
download | volse-hubzilla-e466d72058b2543bec69c77d2730828acada38a1.tar.gz volse-hubzilla-e466d72058b2543bec69c77d2730828acada38a1.tar.bz2 volse-hubzilla-e466d72058b2543bec69c77d2730828acada38a1.zip |
adjust birthday handling according to community decision and slightly change display of allday event items
Diffstat (limited to 'include/event.php')
-rw-r--r-- | include/event.php | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/include/event.php b/include/event.php index eb8731f46..ca08a67b5 100644 --- a/include/event.php +++ b/include/event.php @@ -76,18 +76,34 @@ function format_event_obj($jobject) { if(array_key_exists('description', $object)) { $tz = (($object['timezone']) ? $object['timezone'] : 'UTC'); + $allday = (($object['adjust']) ? false : true); - $bd_format = t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8:01 AM + $dtstart = new DateTime($object['dtstart']); + $dtend = new DateTime($object['dtend']); + $dtdiff = $dtstart->diff($dtend); + + if($allday && ($dtdiff->days < 2)) + $oneday = true; + + if($allday && !$oneday) { + // Subtract one day from the end date so we can use the "first day - last day" format for display. + $dtend->modify('-1 day'); + $object['dtend'] = datetime_convert('UTC', 'UTC', $dtend->format('Y-m-d H:i:s')); + } + + $bd_format = (($allday) ? t('l F d, Y') : t('l F d, Y \@ g:i A')); // Friday January 18, 2011 @ 8:01 AM or Friday January 18, 2011 for allday events $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array( '$title' => zidify_links(smilies(bbcode($object['title']))), - '$dtstart_label' => t('Starts:'), + '$dtstart_label' => t('Start:'), '$dtstart_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), '$finish' => (($object['nofinish']) ? false : true), - '$dtend_label' => t('Finishes:'), + '$dtend_label' => t('End:'), '$dtend_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))) + '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))), + '$allday' => $allday, + '$oneday' => $oneday )); $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( |