The Date Issue

Wow. That was deceptively easy to fix. Why the hell couldn’t I figure it out last night?

For the interested, here is the problem and its solution:

I had to move over my old entries from Greymatter into BlogWorks XML. This involved copy/pasting all entries one by one (there were only about 20 of them), then changing the dates of each one. The problem was, however, that the “timestamp” XML elements/variable/whatever, used to state the time and date of the post, was derived using a formula in a function called “HumanToUnix” that basically converted everything to the number of seconds from 1/1/1970 (I think). After attempting to puzzle out the formula to create the timestamp variable and the blogID and post ID variables (all related), I gave up and copied the formula into an ASP page of my own. I type in the day, month, year, hour (0-23), and minutes, the app spits out a timestamp. Fine. So I change all the timestamps to the dates in which the original entries had been entered.

When the main page and the archives are rendered by the BlogWorks engine, however, the timestamp is pulled from the blog id, not the actual timestamp variable, then converted back using a function called UnixToHuman. So change the variable used to the timestamp variable, right? Wrong. I couldn’t make heads or tales of the array used in extracting the data from the XML file, and messed up the pages several times trying. The logic of the date display (as in, whether to display it or not) is something like: if the date of the current entry is the same as the date of the last, just don’t show a date. Otherwise, go ahead and display it. But the old and current dates were using the date pulled from the blog id, which I couldn’t really mess with. There was a variable called “bdatetime” that was used in displaying the date in place of the [date] holder, however. I tried setting this variable equal to the date of the current entry, then using VBScript functions such as CDate() on it when that did not work, to no avail. I could never make the old date equal the date of the current date, meaning the date was printed for every entry. So I narrowly avoided punching my computer, made my post of frustration last night, and surfed the Internet for a while.

This afternoon, after lying in bed reading since about 6:00 am, I decided to give it another go. So I looked again at the engine code, found the conversion done on bdatetime when displaying the date and performed that same conversion on my currentDate = bdatetime line. And lo and behold, it worked. Now why couldn’t I figure that out last night?