Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-03-26 21:37:02

etc
Developer
Registered: 2010-11-11
Posts: 3,042
Website

etc_date : custom dates and calendars

Textpattern has localized strings for almost everything, but dates are under servers responsibility. This is reasonable, since dates are more than just months/days names, but can be a problem if some locales are not installed on the server. For example, if ru_RU locale is not available on your server, <txp:posted /> will output something like March 26, 09:21 PM, even if you switch Textpattern current language to Russian.

This is where etc_date intervenes. It allows you to define your own date strings and output dates in the language of your choice. Moreover, you can use custom calendars, to output something like 18 Brumaire An VIII (though currently only Gregorian and Hijri calendars are available).

More info and download.


etc_[ query | search | pagination | date | tree | cache ]

Offline

#2 2013-03-29 20:53:33

etc
Developer
Registered: 2010-11-11
Posts: 3,042
Website

Re: etc_date : custom dates and calendars

Small update (v.0.2.2) to include Jalali calendar (knowledgeable testers needed).

Attention: locale attribute is renamed to lang, to avoid clashes with global variables and to comply avec <txp:posted /> attributes.


etc_[ query | search | pagination | date | tree | cache ]

Offline

#3 2013-03-31 11:14:52

etc
Developer
Registered: 2010-11-11
Posts: 3,042
Website

Re: etc_date : custom dates and calendars

Version 0.2.5: introduces <txp:etc_if_date /> tag:

<txp:etc_if_date value="12-25" format="%m-%d">
	Merry Christmas!
</txp:etc_if_date>

etc_[ query | search | pagination | date | tree | cache ]

Offline

#4 2013-03-31 15:01:03

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,048
Website

Re: etc_date : custom dates and calendars

etc wrote:

Version 0.2.5: introduces <txp:etc_if_date /> tag:

I could use this:)

Thanks soo much Oleg. I’ll be giving your plugin a try.


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github

Offline

#5 2013-03-31 15:28:03

etc
Developer
Registered: 2010-11-11
Posts: 3,042
Website

Re: etc_date : custom dates and calendars

colak wrote:

I could use this:)

It does not help much in retrieving money from a bank, I’m afraid :) Good luck, Yiannis, I have experienced it in 90’s in Russia, loosing every ruble I had (that was not much), and life still goes on.


etc_[ query | search | pagination | date | tree | cache ]

Offline

#6 2013-04-01 05:58:18

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,048
Website

Re: etc_date : custom dates and calendars

etc wrote:

It does not help much in retrieving money from a bank, I’m afraid :)

Hey Oled, Why didn’t you mention this before I installed it? It’s what I needed it for:)


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github

Offline

#7 2013-04-03 04:54:08

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,048
Website

Re: etc_date : custom dates and calendars

Hi Oleg is there a way to have a conditional on a range of dates?

Something like

<txp:etc_if_date from="1-25" to="2-16" format="%m-%d">
	Range specific message
</txp:etc_if_date>

Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github

Offline

#8 2013-04-03 13:10:25

etc
Developer
Registered: 2010-11-11
Posts: 3,042
Website

Re: etc_date : custom dates and calendars

Hi Yiannis, thanks for your proposal. It surely makes sense and is easy to implement for literal comparisons. I wouldn’t like to multiply attributes, though. What do you think of value="1-25..2-16" or something like this to specify a range?

That’s more tricky to do consistently for non-literal comparisons, due to the “international” nature of the plugin. Imagine that someone wants

<txp:etc_if_date from="25 January" to="16 February" format="%d %B">
	Range specific message
</txp:etc_if_date>

We can not do literal comparison here, so we have to convert dates to timestamps. It would be ok for default locales, but how to do with custom locales/calendars:

<txp:etc_if_date from="14 Farvardin 1392" to="14 Esphand 1394" lang="fa_IR" calendar="jalali" format="%d %B %Y">
	Range specific message
</txp:etc_if_date>

PHP has no idea of what Farvardin is, so we have to provide a converter to timestamp for every calendar/locale/format combination…

BTW, etc_query can also be used as universal conditional plugin:

<txp:etc_query functions="date" query="date('md') >= '0125' and date('md') <= '0216'">
	Range specific message
</txp:etc_query>

etc_[ query | search | pagination | date | tree | cache ]

Offline

#9 2013-04-03 13:28:37

phuture303
Member
Registered: 2008-09-14
Posts: 127

Re: etc_date : custom dates and calendars

colak schrieb:

<txp:etc_if_date from=“1-25” to=“2-16” format=”%m-%d”> Range specific message
</txp:etc_if_date>

Hi colak,

depending of what you want to do you should have a look at pat_timer. I’m using it for registration forms (hide/live soon -> live/registration open -> hide again/registration closed) with success.

Example (looks weird I know…)

<txp:pat_timer start="2012-01-01" end="2013-03-31 20:00">
	<txp:upm_textile>
		<txp:custom_field name="anmeldung-text-bald" escape=""/>
	</txp:upm_textile>
</txp:pat_timer>
<txp:pat_timer start="2013-03-31 20:00" end="2013-04-14 20:00">
	<txp:upm_textile>
		<txp:custom_field name="anmeldung-text-ja" escape=""/>
	</txp:upm_textile>
	<txp:output_form form="anmeldeformular_machform" />
</txp:pat_timer>
<txp:pat_timer start="2013-04-14 20:00" end="2013-12-31">
	<txp:upm_textile>
		<txp:custom_field name="anmeldung-text-nein" escape=""/>
	</txp:upm_textile>
</txp:pat_timer>

David

Edit: Added code blocks to make it readable..

Last edited by jstubbs (2013-04-03 14:43:32)

Offline

#10 2013-04-03 14:59:53

etc
Developer
Registered: 2010-11-11
Posts: 3,042
Website

Re: etc_date : custom dates and calendars

Done as described above, please test, e.g.

<txp:etc_if_date date="-2 months" value="01-25..02-16" format="%m-%d">
	Range specific message
</txp:etc_if_date>

Multiple ranges are possible too:

<txp:etc_if_date value="01-25..02-16 | 04-03" format="%m-%d">
	Range specific message
<txp:else />
	Out of range
</txp:etc_if_date>

Last edited by etc (2013-04-04 10:28:52)


etc_[ query | search | pagination | date | tree | cache ]

Offline

Board footer

Powered by FluxBB