[solved] CGCalendar All Day Time is showing as 1:15 AM?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
rbaby
Forum Members
Forum Members
Posts: 144
Joined: Thu Feb 07, 2008 10:28 pm

[solved] CGCalendar All Day Time is showing as 1:15 AM?

Post by rbaby »

I have some events that have a start time, some events with an end time, and some with no time at all and specified to All Day. However, the following template in the default which shows:

Code: Select all

	{if $event.event_date_start == $event.event_date_end || $event.event_date_end == 0}
	<div class="calendar-date-from">{$event.event_date_start|date_format:'%B %e, %Y %l:%M %p'}</div>
	{else}
	{if $event.event_date_start|date_format:"%d%m%Y" == $event.event_date_end|date_format:"%d%m%Y"}
	<div class="calendar-date-from">{$event.event_date_start|date_format:'%B %e, %Y %l:%M %p'} {$lang.to} {$event.event_date_end|date_format:"%l:%M %p"}</div>
	{else}
	<div class="calendar-date-from">{$event.event_date_start|date_format:'%B %e, %Y %H:%M'} {$lang.to} {$event.event_date_end|date_format:"%B %e, %Y %H:%M"}</div>
	{/if}
My all-day events are appearing as 1:15 AM. How can I address this or add another if statement to not display time if it's set to All Day?

Thanks!
Last edited by rbaby on Wed May 06, 2015 7:49 am, edited 1 time in total.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: CGCalendar All Day Time is showing as 1:15 AM?

Post by velden »

you could add some code in the template and print out the contents of each event variable. Then find the property that tells you it's an all day event and use that in the template.

Code: Select all

{foreach .... item=event}
...
<pre>{$event|print_r}</pre>
...
{/foreach}

rbaby
Forum Members
Forum Members
Posts: 144
Joined: Thu Feb 07, 2008 10:28 pm

Re: CGCalendar All Day Time is showing as 1:15 AM?

Post by rbaby »

Thanks velden! That print really helped...I was struggling a bit with the error but I realized that I was missing a closing {/if} statement. For anyone who is looking for a solution, this is what I ended up with:

Code: Select all

   {if $event.event_all_day == 1}
   <div class="calendar-date-from">{$event.event_date_start|date_format:'%B %e, %Y'}</div>
   {else}
   {if $event.event_date_start == $event.event_date_end || $event.event_date_end == 0}
   <div class="calendar-date-from">{$event.event_date_start|date_format:'%B %e, %Y %l:%M %p'}</div>
   {else}
   {if $event.event_date_start|date_format:"%d%m%Y" == $event.event_date_end|date_format:"%d%m%Y"}
   <div class="calendar-date-from">{$event.event_date_start|date_format:'%B %e, %Y %l:%M %p'} {$lang.to} {$event.event_date_end|date_format:"%l:%M %p"}</div>
   {else}
   <div class="calendar-date-from">{$event.event_date_start|date_format:'%B %e, %Y %H:%M'} {$lang.to} {$event.event_date_end|date_format:"%B %e, %Y %H:%M"}</div>
   {/if}
   {/if}
   {/if}
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: [solved] CGCalendar All Day Time is showing as 1:15 AM?

Post by velden »

You could consider using {elseif ....} for readability and preventing the nesting. Further try to not repeat 'code' if not necessary (the div is the same for any condition, so put it outside the condition.

(untested:)

Code: Select all

<div class="calendar-date-from">
{if $event.event_all_day == 1}
  {$event.event_date_start|date_format:'%B %e, %Y'}
{elseif $event.event_date_start == $event.event_date_end || $event.event_date_end == 0}
  {$event.event_date_start|date_format:'%B %e, %Y %l:%M %p'}
{elseif $event.event_date_start|date_format:"%d%m%Y" == $event.event_date_end|date_format:"%d%m%Y"}
  {$event.event_date_start|date_format:'%B %e, %Y %l:%M %p'} {$lang.to} {$event.event_date_end|date_format:"%l:%M %p"}
{else}
  {$event.event_date_start|date_format:'%B %e, %Y %H:%M'} {$lang.to} {$event.event_date_end|date_format:"%B %e, %Y %H:%M"}
{/if}
</div>
rbaby
Forum Members
Forum Members
Posts: 144
Joined: Thu Feb 07, 2008 10:28 pm

Re: [solved] CGCalendar All Day Time is showing as 1:15 AM?

Post by rbaby »

Thank you, I will try it :)
Post Reply

Return to “Modules/Add-Ons”