This is vary much like the other question with the similar name, however instead limit answers to XSLT1.0. I'm also removing the attribute, make this easy. Plus this timestamp is 3 digits shorter.
I have an XML with timestamps like this:
<node><stamp>1236888746</stamp></node>
<node><stamp>1360954731</stamp></node>
And I would like to display them in the result HTML as date with time. Is there a way to do it with XSLT that would run on a browser?
Edit: This does not work as intended, seems like a math problem. A leap is four years, starting at just after February 29th, 1970 if you must. The math I've laid out produces incorrect results. The counting of months part I've tested in xPath, bools are 0 or 1 and adding them together just like below produces an integer result.
<xsl:variable name="leapoffset" select="31 + 29"/>
<xsl:variable name="leapdays" select="31 * 4 * 7 + 30 * 4 * 4 + 28 * 4 + 1"/>
<!-- Enter loop -->
<xsl:variable name="days" select="round(stamp div 86400 - 0.5)"/>
<xsl:variable name="leaps" select="round(($days - $leapoffset) div $leapdays + $leapoffset div $leapdays - 0.5)"/>
<xsl:variable name="dayofleap" select="$days - $leaps * $leapdays + $leapoffset - 1"/>
<xsl:variable name="tmp" select="0 +
($dayofleap > 31) * 31745 +
($dayofleap > 61) * 30721 +
($dayofleap > 92) * 31745 +
($dayofleap > 122) * 30721 +
($dayofleap > 153) * 31745 +
($dayofleap > 184) * 31745 +
($dayofleap > 214) * 30721 +
($dayofleap > 245) * 31745 +
($dayofleap > 275) * 30721 +
($dayofleap > 306) * 31745 +
($dayofleap > 337) * 31745 +
($dayofleap > 365) * 28673 +
($dayofleap > 396) * 31745 +
($dayofleap > 426) * 30721 +
($dayofleap > 457) * 31745 +
($dayofleap > 487) * 30721 +
($dayofleap > 518) * 31745 +
($dayofleap > 549) * 31745 +
($dayofleap > 579) * 30721 +
($dayofleap > 610) * 31745 +
($dayofleap > 640) * 30721 +
($dayofleap > 671) * 31745 +
($dayofleap > 702) * 31745 +
($dayofleap > 730) * 28673 +
($dayofleap > 761) * 31745 +
($dayofleap > 791) * 30721 +
($dayofleap > 822) * 31745 +
($dayofleap > 852) * 30721 +
($dayofleap > 883) * 31745 +
($dayofleap > 914) * 31745 +
($dayofleap > 944) * 30721 +
($dayofleap > 975) * 31745 +
($dayofleap > 1005) * 30721 +
($dayofleap > 1036) * 31745 +
($dayofleap > 1067) * 31745 +
($dayofleap > 1095) * 28673 +
($dayofleap > 1126) * 31745 +
($dayofleap > 1156) * 30721 +
($dayofleap > 1187) * 31745 +
($dayofleap > 1217) * 30721 +
($dayofleap > 1248) * 31745 +
($dayofleap > 1279) * 31745 +
($dayofleap > 1309) * 30721 +
($dayofleap > 1340) * 31745 +
($dayofleap > 1370) * 30721 +
($dayofleap > 1401) * 31745 +
($dayofleap > 1432) * 31745 +
($dayofleap > 1461) * 29697
"/>
<xsl:variable name="monthofleap" select="($tmp mod 1024) + 2"/>
<xsl:variable name="day" select="$dayofleap - round($tmp div 1024 - 0.5)"/>
<xsl:variable name="yearofleap" select="round($monthofleap div 12 - 0.5)"/>
<xsl:variable name="years" select="$leaps * 4 + $yearofleap"/>
<xsl:variable name="month" select="$monthofleap mod 12"/>
<xsl:value-of select="$years + 1970"
/>-<xsl:value-of select="format-number($month, '00')"
/>-<xsl:value-of select="format-number($day, '00')"
/>T<xsl:value-of select="format-number(round(stamp div 3600 - 0.5) mod 24, '00')"
/>:<xsl:value-of select="format-number(round(stamp div 60 - 0.5) mod 60, '00')"
/>:<xsl:value-of select="format-number(stamp mod 60, '00')"/>
Let me explain line by line, because I don't like comments in code. Actually I don't like comments at all, these don't reflect the code above exactly for example. I'm not good at explaining code in any other language then the one the code is written, which is good because if you can understand what I'm trying to do because of my explanation and not because you read the above code then I'd be amazed if you are of help to me. The first two are global constants, the number of days from the Epoch to Feb 29th and the number of days in four years. Convert ticks to days. Try to figure out how many leap days since the Epoch. How many days since the last Feb 29th. Count the months since the start of the leap adding one for each month boundary, vary long equation 48 months in a leap so there are 48 bools, with the higher order bits used to store/count the number of days that have passed in other months not belonging to the current month. A number(0 to 5) representing the number of years that have passed since 2 months(Jan 1st) prior to this leap. The number of years since Epoch. A number representing the number of months that have passed since 2 months(Jan 1st) prior to this leap.