Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Seasons dates logic

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
cwebnet
Smarty n00b


Joined: 23 Dec 2009
Posts: 3

PostPosted: Wed Dec 23, 2009 12:41 pm    Post subject: Seasons dates logic Reply with quote

Hi all,
i need your help to do a logic of Seasons dates, i have done something but seems not work correctly, I will appreciate all your help, thanks.



Code:
{assign var="date_now"  value=$smarty.now|date_format:"%Y/%m/%d"}
{assign var="date_year"  value=$smarty.now|date_format:"%Y"}

{assign var="default"  value="default"}

{assign var="spring" value="$date_year/03/21"}
{assign var="summer" value="$date_year/06/21"}
{assign var="fall" value="$date_year/09/21"}
{assign var="winter" value="$date_year/12/21"}

{if $spring >= $date_now} -> Spring
{elseif $summer >= $date_now} -> Summer
{elseif $fall >= $date_now} -> Fall
{elseif $winter >= $date_now} -> Winter 

{else}

{$default}

{/if}
[/code]
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Dec 23, 2009 4:02 pm    Post subject: Reply with quote

Why not make a plugin and do this in PHP? Then the template would just be:

{show_season}
Back to top
View user's profile Send private message Visit poster's website
cwebnet
Smarty n00b


Joined: 23 Dec 2009
Posts: 3

PostPosted: Wed Dec 23, 2009 4:22 pm    Post subject: Reply with quote

mohrt wrote:
Why not make a plugin and do this in PHP? Then the template would just be:

{show_season}


Thanks yup i did this in php yes, but i want in smarty Smile, so I did this and seems to work, what is your opinion?

Code:
{assign var="season" value='z'|date}

{if $season <= 164 and $season >= 70}
Spring
 {else}

{if $season <= 295 and $season >= 165}
Summer
{else}

{if $season <= 327 and $season >= 296}
Autumn
{else}
Winter

{/if}
{/if}
{/if}
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Dec 23, 2009 4:27 pm    Post subject: Reply with quote

If it works for you. I'd rather put all that stuff in a plugin.
Back to top
View user's profile Send private message Visit poster's website
cwebnet
Smarty n00b


Joined: 23 Dec 2009
Posts: 3

PostPosted: Wed Dec 23, 2009 4:38 pm    Post subject: Reply with quote

mohrt wrote:
If it works for you. I'd rather put all that stuff in a plugin.


It's an idea yes, thanks for your answers!
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP