# Generating dynamic content with MediaWiki/2009

OK. It's 20240920172741 - That's from the as you should know. Generating dynamic content with MediaWiki is something that we do "on the fly" as time goes by. It's a pretty good indication that the Humans, bots and dynamic pages are populated when you see content changing a lot. This part of the study is from mw:Help:Extension:ParserFunctions in the MediaWiki Handbook that all users and sysops should be familiar with.

## This Year

We're going to break it all down.
The parser function #time breaks down the {{CURRENTTIMESTAMP}}:
[[{{#titleparts:{{FULLPAGENAME}}|2|1}}|{{#time:Y|{{CURRENTTIMESTAMP}}}}]] to give us:
We Used [[{{#titleparts:{{FULLPAGENAME}}|2|1}}]] to hide our main namespace title which is rather long.

## Today

Today is Friday
Now, depending on your language's support, that should evaluate to a friendly name for the DOW - Day Of the Week. As I'm writing this it is:
To make it a bit friendlier we use
..to give us a snapshot marking the beginning of this part of the project. We can call that a record.
MediaWiki is very good at keeping track of things that happened in the past on wikis like Wikipedia and Wikiversity, so we're not too concerned about using its dynamics to track the past. What we want to do is use MediaWiki's parser functions to build a structure for the future. To do that we need to look at numeric representations of yesterday, today and tomorrow to get a sense of what dynamic content is about. We can call this a project!

## Tomorrow

Tomorrow = today + 1
There are several ways we can look at today as a numeric value. Arguably, the most natural way of looking at a day is as one rotation of the Earth around its axis. That rotation is relative to to other nearby bodies floating out here with us in space, notably the Sun and the Moon. A Day in relation to the Sun is of course the Day of the Year. For that, MediaWiki uses the z argument:
So as we go through the Year, this numeric position is unique over the range 001 .. 365 (366 in leap years). Usining Y and z together, these form ordinal dates and are pretty handy.
* A year ago today: {{#expr:{{#time:Y|{{CURRENTTIMESTAMP}}}}-1}}-{{#time:z|{{CURRENTTIMESTAMP}}}} => 2023-263
* Yesterday: {{#time:Y|{{CURRENTTIMESTAMP}}}}-{{#expr:{{#time:z|{{CURRENTTIMESTAMP}}}}-1}} => 2024-262
* Today: {{#time:Y|{{CURRENTTIMESTAMP}}}}-{{#time:z|{{CURRENTTIMESTAMP}}}} => 2024-263
* Tomorrow: {{#time:Y|{{CURRENTTIMESTAMP}}}}-{{#expr:{{#time:z|{{CURRENTTIMESTAMP}}}}+1}} => 2024-264
* A year from today: {{#expr:{{#time:Y|{{CURRENTTIMESTAMP}}}}+1}}-{{#time:z|{{CURRENTTIMESTAMP}}}} => 2025-263
I know it's not pretty or easy to do manually, but MediaWiki parser functions can be used to build tools and tables for dynamic content that regular folks can appreciate. These examples themselves are always going to be current. The code:
Will produce a "prettytable" on most wikis running MediaWiki.

## This Week

This week is 2024-W38 and today is Friday or Day #5 of that week.
That is dynamic, thus still true for the both of us. So now we want to see what the future looks like. What's in the future for me, is in the past for you. As I sit here, the Earth, Sun and Moon articles are only 2/3 started. One is a red link. The Sun module is a stub about Sun Microsystems and not about the celestial orb at all. The Earth module is a learning resourse about our planet and the Moon module is non-existent. This week and for all weeks to come the red link page is to remain non-existent, so it has a policy-directed status with no expiry.
Since I'm in 2009-W36 I'll move this to a subpage -> [[/W{{#time:W|{{subst:CURRENTTIMESTAMP}}}}]] => /W36

## This Month

Wikiversity:Welcome log/2009/09