Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2024-03-31 21:01:05

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,446
Website GitHub

Re: Outputting current date

Yeah, this one takes all bank holidays into account, and has to skip them to work out the next available delivery dates after that. It’s a monster.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#17 2024-03-31 22:28:03

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

Re: Outputting current date

jakob wrote #336996:

Wow! Excellent! Was this something you’d tried before or did you concoct this just now? Either way, in very brief testing for now it works as advertised. Big thanks!!

Basically, just renamed posted() function, a five minutes work :-)

Other time-related functionality I can think of is:

  • compare against some specified time so that one can display something related to a particular time, e.g. “show from__” or “show until __”.
  • formatting from->to dates. I currently have a custom solution for this, but what makes it tricky is finding a simple way to define attributes for the various combinations across time unit boundaries, e.g. 3 – 6 April 2024, 31 March – 2 April 2024, 25 December 2023 – 6 January 2024, etc. In German, I typically have two variants: one verbose as described and one concise with the 03. – 06.04.24, 31.03. – 02.04.24, 25.12.23 – 06.01.24, so I have these hard-coded in my own version.

Comparing against a given range(s) is doable (IIRC etc_date does it). As for from->to output, for a given language it looks as easy as two <txp:date /> combination (with different format). But, as Stef says, a universally valid output in different languages/calendars looks tricky.

Offline

#18 2024-04-01 00:41:07

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,638
Website

Re: Outputting current date

etc wrote #336992:

I’ve just added <txp:date /> tag to dev, please test and suggest feature ideas. Currently it works e.g. like this:

<txp:date gmt time="now" lang="de" calendar="hebrew" format="%Y %b" />...

Lovely… Works great so far! Thanks you.

(bye bye another PHP snippet)


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

Board footer

Powered by FluxBB