Textpattern CMS support forum

You are not logged in. Register | Login | Help

#21 2017-01-31 13:02:38

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

Re: etc_date : custom dates and calendars

No worries, sorry for often being terse. I have a bit forgotten myself how it works, but you got it all right: value is not computed, but compare is (note that date is always computed).

Let us add two examples, for the record:

  • you need to detect if tomorrow is a working day (from Monday to Friday):
    <txp:etc_if_date date="tomorrow" format="%u" value="1..5" />
    will compute tomorrow weekday number and check if it is between 1 and 5 (inclusively)
  • you need to detect whether Christmas is within 3 days:
    <txp:etc_if_date date="25 December" format="%s" compare="-3 days..+3 days" />
    will compute and compare the timestamps of 25 December and +-3 days (from now). Here we don’t know which value +-3 days will have, so we need to compute it first.

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

Offline

#22 2017-01-31 13:11:39

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 3,388
Website

Re: etc_date : custom dates and calendars

Thanks, having that discussion helped me understand it better. If you like – once I’ve tested my code properly – I can contribute some examples for your plugin help.


TXP Builders – finely-crafted code, design and txp

Offline

#23 2017-01-31 15:18:36

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

Re: etc_date : custom dates and calendars

jakob wrote #303758:

If you like – once I’ve tested my code properly – I can contribute some examples for your plugin help.

You are welcome! Just fwiw, in 4.7 we have enhanced month and time attributes of article(_custom). It can retrieve articles posted between two (absolute or relative) dates now, though it probably does not help in your case.


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

Offline

#24 2017-10-08 05:40:52

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 241

Re: etc_date : custom dates and calendars

how to convert comment date to jalali format ?

Offline

#25 2017-10-08 11:07:47

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

Re: etc_date : custom dates and calendars

Try to replace <txp:comment_time /> in comments form with

<txp:etc_date timestamp='<txp:comment_time format="%s" />'
    calendar="jalali" lang="fa_IR" format="%d %B %Y" />

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

Offline

Board footer

Powered by FluxBB