By using the days-from-date function, you can convert the date in the form 2008-08-22T08:54:21-05:00 or 2008-08-30 into the number of days that have elapsed since January 1, 1970. You can use this to calculate the difference between two dates or the amount of time that has passed. The following coding demonstrates the same :
HTML Code:
html xmlns="URL/xhtml"
xmlns:xforms="URL1/xforms">
<head>
<title>Days until Christmas</title>
<xforms:model>
<xforms:instance xmlns="">
<variables>
<Now/>
<Year/>
<Christmas/>
<ChristmasDay/>
<Result/>
</variables>
</xforms:instance>
<xforms:bind nodeset="Now" calculate="days-from-date(now())"/>
<xforms:bind nodeset="Year" calculate="substring(now(), 1, 4)"/>
<xforms:bind nodeset="Christmas" calculate="concat(../Year, '-12-25')"/>
<xforms:bind nodeset="ChristmasDay" calculate="days-from-date(../Christmas)"/>
<xforms:bind nodeset="Result" calculate="../ChristmasDay - ../Now"/>
</xforms:model>
</head>
<body>
<h1>
<xforms:output value="Result">
<xforms:label>Days until Christmas: </xforms:label>
</xforms:output>
</h1>
</body>
</html>
You can use the above form for an XForm that counts the days remaining until Christmas.
Bookmarks