Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-12-17 19:37:49

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Conditional Event date display

Hello community,

I search a calendar dates manipulating system
I use <txp:posted /> and <txp:expires /> for display dates of events.

I want display the events dates in diff. formats.

If ( posted{2013-12-17} == expires{2013-12-17} ) // Same day
   display

         17 dec 2013

If ( posted{2013-12-17} < expires{2013-12-20} && posted{month} == expires{month} )  // max diff. 3 days
   display

          17 - 18 - 19 dec 2013

if ( posted{2013-12-17} < expires{2014-01-12} // sup 3 days or diff month
   display

          17 dec 2013 -> 12 jan 2013

I think I’m looking for a tool that returns the number of days between two dates and the number of each days.

A idea ? Thanks

Last edited by sacripant (2013-12-17 19:38:46)

Offline

#2 2013-12-17 20:18:33

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,356
GitHub

Re: Conditional Event date display

I don’t have an answer for you, but I am pretty confident Oleg ‘etc’ will be here in very soon with a way that etc_query can do exactly what you want.

Offline

#3 2013-12-17 23:17:18

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,925
Website GitHub

Re: Conditional Event date display

Sacripant, a long time ago, Ruud helped me out with something similar, although the source was dates held in custom fields and the equivalent to your “same month” date display was a bit more succinct. See this post and the comments that follow.


TXP Builders – finely-crafted code, design and txp

Offline

#4 2013-12-18 12:21:23

etc
Developer
Registered: 2010-11-11
Posts: 5,393
Website GitHub

Re: Conditional Event date display

gaekwad wrote:

I don’t have an answer for you, but I am pretty confident Oleg ‘etc’ will be here in very soon with a way that etc_query can do exactly what you want.

We are selling light weapons too, try this:

<txp:etc_if_date date="expires" compare="posted" format="%Y-%m">
	<txp:etc_if_date date="expires" compare="posted +1 day.." format="%d">
		<txp:posted format="%d" /> -
	</txp:etc_if_date>
	<txp:etc_if_date date="expires" compare="posted +2 days..posted +3 days" format="%d">
		<txp:etc_date date="posted +1 days" format="%d" /> -
	</txp:etc_if_date>
	<txp:etc_if_date date="expires" compare="posted +3 days" format="%d">
		<txp:etc_date date="posted +2 days" format="%d" /> -
	</txp:etc_if_date>
	<txp:expires />
<txp:else />
	<txp:posted /> - <txp:expires />
</txp:etc_if_date>

Offline

#5 2013-12-18 18:41:56

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: Conditional Event date display

@all

thanks! I test

Offline

Board footer

Powered by FluxBB