Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 Today 12:30:50

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

Re: Correct syntax for variable output multiple times

Yes, I’d forgotten about alias too, so seeing it in use here is a great reminder on its power. Thank you, Oleg!


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

#14 Today 12:36:50

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

Re: Correct syntax for variable output multiple times

I also see that Oleg has updated his solution to include the leap year in a “dark” variable. That’s neat.

Does that also apply to the “light” one too, since the 80 days DST switchover is after Feb 29th? Or have I misunderstood the relevance of the 80/264? I haven’t fully grokked the solution.


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 Today 14:01:13

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

Re: Correct syntax for variable output multiple times

jakob wrote #341087:

how a programmer goes about it.

Thanks, but I’m just fond of conciseness, a true programmer would write 5 lines of comments per line of code :-)

Offline

#16 Today 14:07:33

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

Re: Correct syntax for variable output multiple times

Bloke wrote #341089:

Does that also apply to the “light” one too, since the 80 days DST switchover is after Feb 29th? Or have I misunderstood the relevance of the 80/264? I haven’t fully grokked the solution.

I guess yes, if the switch always happens the March/September 21st. But I preferred to win one Light day. Or simply goofed :-)

Offline

#17 Today 19:47:18

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

Re: Correct syntax for variable output multiple times

I leave a thread for 36 hours and just look at it. Thank you all very much, I am so grateful.

I’ll explain the numbering in a non-technical sense. I suspect with the combined grey matter around here there’s likely a cleaner solution.

I’m splitting the year into two for a project that I’ve started, the big reveal will likely be in Q1 2026 at this rate. There’s a Dark half of the year, and a Light half of the year. These halves relate to both project ops and some of the site markup & styling.

Where I live, the longest day of the year is typically June 21st and the shortest day is typically December 21st. These dates are the midpoints of the Light and Dark periods on the calendar. I’m using the 21st as the changeover dates for March and September, rather than being absolutely accurate on the number of days in each period. I can map out various days of the year as markers for my sums:

Relevance Date Day #
Begin Year Jan 01 1
End Dark Mar 21 80 / 81
Begin Light Mar 21 80 / 81
Mid Light Jun 21 172 / 173
End Light Sep 21 264 / 265
Begin Dark Sep 21 264 / 265
Mid Dark Dec 21 355 / 356
End Year Dec 31 365 / 366

I’m still twiddling the day numbers as I figure this out, but I can figure out whether it’s Light or Dark based on the current day number. When I know this, I can throw that into an HTML progress or meter to indicate visually how far into the period we are. I can also show how many days into the Light or Dark period we are, and therefore how many days until the changeover. That’s the plan, anyway…I’m doing this in the evenings after some grotty day job work that’s sapping my energy, and it’s slow work.

The sums are a bit of a bodge in some cases – but they do seem to work. The Dark period straddling the year break was a bit of a challenge since the day number resets from 365 (or 366) to 1 mid-period.

Hope this sheds a bit of light!

Last edited by gaekwad (Today 19:49:20)

Offline

Board footer

Powered by FluxBB