User blog:JoshuaJSlone/Age / time improvement

A few months back templates like Template:Birthday and Template:Age were brought in so people wouldn't have to keep manually updating ages. The problem was this wiki prefers to go by JST (Japan Standard Time), but by default Wikia uses UTC (Coordinated Universal Time). I made some modifications to Age so it would more closely match, but it was an imperfect fix--notably birthdays on the first of a month wouldn't properly get noticed when it was the last day of the previous month. Also adding in new exceptions made the code more complicated and hard to follow, so I really wasn't wanting to try and fix it further and make it even harder to follow. Today I found a different solution that is both a lot simpler to look at, and should work in all cases.

24 by default uses time functions like August and 27. However, I learned there's a more generic time function that can give you the same results, like and. Even better, you can tell it to add and subtract time, and so effectively get the current time in a different time zone. For Japan, that means and. To keep things simple I went ahead and put these into template pages named very similarly to the standard ones, but with JST added to the end. So now there is, , , and. With these in, I could go back to the original simpler version of 24 and just toss the JST in there when appropriate. So those and the current 24 are the ones to copy if you want to use this solution on another wiki.

The only problem is that it'll take a few more days before I can actually confirm that it's now working properly at the end of a month.

CURRENTHOUR: CURRENTDAY: 27 CURRENTMONTH: August CURRENTYEAR: 2024

CURRENTHOURJST: CURRENTDAYJST: CURRENTMONTHJST: CURRENTYEARJST: