Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2024-03-31 19:59:41

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

Re: Outputting current date

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!!

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.

Whether or not these pass the “bloatware” test ;-) I’m happy to have this new tag in our tool belt. Thank you.


TXP Builders – finely-crafted code, design and txp

Offline

#14 2024-03-31 20:32:30

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

Re: Outputting current date

Date ranges are an absolute mare. And virtually impossible to code across languages in a meaningful way.

I’ve got a delivery date range Shortcode for a client, and the Form that outputs that one line is about 175 lines of PHP.


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

Txp Builders – finely-crafted code, design and Txp

Offline

#15 2024-03-31 20:45:45

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

Re: Outputting current date

Bloke wrote #336998:

Date ranges are an absolute mare. And virtually impossible to code across languages in a meaningful way.

I’ve got a delivery date range Shortcode for a client, and the Form that outputs that one line is about 175 lines of PHP.

Wow. Mine is obviously a lot simpler. This mini plugin is what I use for my own use.


TXP Builders – finely-crafted code, design and txp

Offline

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,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.

Txp Builders – finely-crafted code, design and Txp

Offline

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

etc
Developer
Registered: 2010-11-11
Posts: 5,188
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: Japan
Registered: 2004-02-27
Posts: 3,189
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

Offline

Board footer

Powered by FluxBB