Index: /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.difference.function.xsl
===================================================================
--- /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.difference.function.xsl (revision 296)
+++ /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.difference.function.xsl (revision 296)
@@ -0,0 +1,264 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:date="http://exslt.org/dates-and-times"
+                xmlns:func="http://exslt.org/functions"
+                extension-element-prefixes="date func">
+
+<date:month-lengths>
+   <date:month>31</date:month>
+   <date:month>28</date:month>
+   <date:month>31</date:month>
+   <date:month>30</date:month>
+   <date:month>31</date:month>
+   <date:month>30</date:month>
+   <date:month>31</date:month>
+   <date:month>31</date:month>
+   <date:month>30</date:month>
+   <date:month>31</date:month>
+   <date:month>30</date:month>
+   <date:month>31</date:month>
+</date:month-lengths>
+
+<func:function name="date:difference">
+   <xsl:param name="start" />
+   <xsl:param name="end" />
+
+   <xsl:variable name="start-neg" select="starts-with($start, '-')" />
+   <xsl:variable name="start-no-neg">
+      <xsl:choose>
+         <xsl:when test="$start-neg or starts-with($start, '+')">
+            <xsl:value-of select="substring($start, 2)" />
+         </xsl:when>
+         <xsl:otherwise>
+            <xsl:value-of select="$start" />
+         </xsl:otherwise>
+      </xsl:choose>
+   </xsl:variable>
+   <xsl:variable name="start-no-neg-length" select="string-length($start-no-neg)" />
+   <xsl:variable name="start-timezone">
+      <xsl:choose>
+         <xsl:when test="substring($start-no-neg, $start-no-neg-length) = 'Z'">Z</xsl:when>
+         <xsl:otherwise>
+            <xsl:variable name="tz" select="substring($start-no-neg, $start-no-neg-length - 5)" />
+            <xsl:if test="(substring($tz, 1, 1) = '-' or 
+                           substring($tz, 1, 1) = '+') and
+                          substring($tz, 4, 1) = ':'">
+               <xsl:value-of select="$tz" />
+            </xsl:if>
+         </xsl:otherwise>
+      </xsl:choose>
+   </xsl:variable>
+   <xsl:variable name="end-neg" select="starts-with($end, '-')" />
+   <xsl:variable name="end-no-neg">
+      <xsl:choose>
+         <xsl:when test="$end-neg or starts-with($end, '+')">
+            <xsl:value-of select="substring($end, 2)" />
+         </xsl:when>
+         <xsl:otherwise>
+            <xsl:value-of select="$end" />
+         </xsl:otherwise>
+      </xsl:choose>
+   </xsl:variable>
+   <xsl:variable name="end-no-neg-length" select="string-length($end-no-neg)" />
+   <xsl:variable name="end-timezone">
+      <xsl:choose>
+         <xsl:when test="substring($end-no-neg, $end-no-neg-length) = 'Z'">Z</xsl:when>
+         <xsl:otherwise>
+            <xsl:variable name="tz" select="substring($end-no-neg, $end-no-neg-length - 5)" />
+            <xsl:if test="(substring($tz, 1, 1) = '-' or 
+                           substring($tz, 1, 1) = '+') and
+                          substring($tz, 4, 1) = ':'">
+               <xsl:value-of select="$tz" />
+            </xsl:if>
+         </xsl:otherwise>
+      </xsl:choose>
+   </xsl:variable>
+
+   <xsl:variable name="difference">
+      <xsl:if test="(not(string($start-timezone)) or
+                     $start-timezone = 'Z' or 
+                     (substring($start-timezone, 2, 2) &lt;= 23 and
+                      substring($start-timezone, 5, 2) &lt;= 59)) and
+                    (not(string($end-timezone)) or
+                     $end-timezone = 'Z' or 
+                     (substring($end-timezone, 2, 2) &lt;= 23 and
+                      substring($end-timezone, 5, 2) &lt;= 59))">
+         <xsl:variable name="start-dt" select="substring($start-no-neg, 1, $start-no-neg-length - string-length($start-timezone))" />
+         <xsl:variable name="start-dt-length" select="string-length($start-dt)" />
+         <xsl:variable name="end-dt" select="substring($end-no-neg, 1, $end-no-neg-length - string-length($end-timezone))" />
+         <xsl:variable name="end-dt-length" select="string-length($end-dt)" />
+
+         <xsl:variable name="start-year" select="substring($start-dt, 1, 4) * (($start-neg * -2) + 1)" />
+         <xsl:variable name="end-year" select="substring($end-dt, 1, 4) * (($end-neg * -2) + 1)" />
+         <xsl:variable name="diff-year" select="$end-year - $start-year" />
+         <xsl:choose>
+            <xsl:when test="not(number($start-year) and number($end-year))" />
+            <xsl:when test="$start-dt-length = 4 or $end-dt-length = 4">
+               <xsl:choose>
+                  <xsl:when test="$diff-year &lt; 0">-P<xsl:value-of select="$diff-year * -1" />Y</xsl:when>
+                  <xsl:otherwise>P<xsl:value-of select="$diff-year" />Y</xsl:otherwise>
+               </xsl:choose>
+            </xsl:when>
+            <xsl:when test="substring($start-dt, 5, 1) = '-' and 
+                            substring($end-dt, 5, 1) = '-'">
+               <xsl:variable name="start-month" select="substring($start-dt, 6, 2)" />
+               <xsl:variable name="end-month" select="substring($end-dt, 6, 2)" />
+               <xsl:variable name="diff-month" select="$end-month - $start-month" />
+               <xsl:choose>
+                  <xsl:when test="not($start-month &lt;= 12 and $end-month &lt;= 12)" />
+                  <xsl:when test="$start-dt-length = 7 or $end-dt-length = 7">
+                     <xsl:variable name="months" select="$diff-month + ($diff-year * 12)" />
+                     <xsl:variable name="abs-months" select="$months * ((($months >= 0) * 2) - 1)" />
+                     <xsl:variable name="y" select="floor($abs-months div 12)" />
+                     <xsl:variable name="m" select="$abs-months mod 12" />
+                     <xsl:if test="$months &lt; 0">-</xsl:if>
+                     <xsl:text>P</xsl:text>
+                     <xsl:if test="$y"><xsl:value-of select="$y" />Y</xsl:if>
+                     <xsl:if test="$m"><xsl:value-of select="$m" />M</xsl:if>
+                  </xsl:when>
+                  <xsl:when test="substring($start-dt, 8, 1) = '-' and
+                                  substring($end-dt, 8, 1) = '-'">
+                     <xsl:variable name="start-day" select="substring($start-dt, 9, 2)" />
+                     <xsl:variable name="end-day" select="substring($end-dt, 9, 2)" />
+                     <xsl:if test="$start-day &lt;= 31 and $end-day &lt;= 31">
+                        <xsl:variable name="month-lengths" select="document('')/*/date:month-lengths/date:month" />
+                        <xsl:variable name="start-y-1" select="$start-year - 1" />
+                        <xsl:variable name="start-leaps" 
+                                      select="floor($start-y-1 div 4) -
+                                              floor($start-y-1 div 100) +
+                                              floor($start-y-1 div 400)" />
+                        <xsl:variable name="start-leap" select="(not($start-year mod 4) and $start-year mod 100) or not($start-year mod 400)" />
+                        <xsl:variable name="start-month-days" 
+                                      select="sum($month-lengths[position() &lt; $start-month])" />
+                        <xsl:variable name="start-days">
+                           <xsl:variable name="days" 
+                                         select="($start-year * 365) + $start-leaps +
+                                                 $start-month-days + $start-day" />
+                           <xsl:choose>
+                              <xsl:when test="$start-leap">
+                                 <xsl:value-of select="$days + 1" />
+                              </xsl:when>
+                              <xsl:otherwise>
+                                 <xsl:value-of select="$days" />
+                              </xsl:otherwise>
+                           </xsl:choose>
+                        </xsl:variable>
+                        <xsl:variable name="end-y-1" select="$end-year - 1" />
+                        <xsl:variable name="end-leaps" 
+                                      select="floor($end-y-1 div 4) -
+                                              floor($end-y-1 div 100) +
+                                              floor($end-y-1 div 400)" />
+                        <xsl:variable name="end-leap" select="(not($end-year mod 4) and $end-year mod 100) or not($end-year mod 400)" />
+                        <xsl:variable name="end-month-days" 
+                                      select="sum($month-lengths[position() &lt; $end-month])" />
+                        <xsl:variable name="end-days">
+                           <xsl:variable name="days" 
+                                         select="($end-year * 365) + $end-leaps +
+                                                 $end-month-days + $end-day" />
+                           <xsl:choose>
+                              <xsl:when test="$end-leap">
+                                 <xsl:value-of select="$days + 1" />
+                              </xsl:when>
+                              <xsl:otherwise>
+                                 <xsl:value-of select="$days" />
+                              </xsl:otherwise>
+                           </xsl:choose>
+                        </xsl:variable>
+                        <xsl:variable name="diff-days" select="$end-days - $start-days" />
+                        <xsl:choose>
+                           <xsl:when test="$start-dt-length = 10 or $end-dt-length = 10">
+                              <xsl:choose>
+                                 <xsl:when test="$diff-days &lt; 0">-P<xsl:value-of select="$diff-days * -1" />D</xsl:when>
+                                 <xsl:otherwise>P<xsl:value-of select="$diff-days" />D</xsl:otherwise>
+                              </xsl:choose>
+                           </xsl:when>
+                           <xsl:when test="substring($start-dt, 11, 1) = 'T' and
+                                           substring($end-dt, 11, 1) = 'T' and
+                                           substring($start-dt, 14, 1) = ':' and
+                                           substring($start-dt, 17, 1) = ':' and
+                                           substring($end-dt, 14, 1) = ':' and
+                                           substring($end-dt, 17, 1) = ':'">
+                              <xsl:variable name="start-hour" select="substring($start-dt, 12, 2)" />
+                              <xsl:variable name="start-min" select="substring($start-dt, 15, 2)" />
+                              <xsl:variable name="start-sec" select="substring($start-dt, 18)" />
+                              <xsl:variable name="end-hour" select="substring($end-dt, 12, 2)" />
+                              <xsl:variable name="end-min" select="substring($end-dt, 15, 2)" />
+                              <xsl:variable name="end-sec" select="substring($end-dt, 18)" />
+                              <xsl:if test="$start-hour &lt;= 23 and $end-hour &lt;= 23 and
+                                            $start-min &lt;= 59 and $end-min &lt;= 59 and
+                                            $start-sec &lt;= 60 and $end-sec &lt;= 60">
+                                 <xsl:variable name="min-s" select="60" />
+                                 <xsl:variable name="hour-s" select="60 * 60" />
+                                 <xsl:variable name="day-s" select="60 * 60 * 24" />
+
+                                 <xsl:variable name="start-tz-adj">
+                                    <xsl:variable name="tz" 
+                                                  select="(substring($start-timezone, 2, 2) * $hour-s) + 
+                                                          (substring($start-timezone, 5, 2) * $min-s)" />
+                                    <xsl:choose>
+                                       <xsl:when test="starts-with($start-timezone, '-')">
+                                          <xsl:value-of select="$tz" />
+                                       </xsl:when>
+                                       <xsl:when test="starts-with($start-timezone, '+')">
+                                          <xsl:value-of select="$tz * -1" />
+                                       </xsl:when>
+                                       <xsl:otherwise>0</xsl:otherwise>
+                                    </xsl:choose>
+                                 </xsl:variable>
+                                 <xsl:variable name="end-tz-adj">
+                                    <xsl:variable name="tz" 
+                                                  select="(substring($end-timezone, 2, 2) * $hour-s) + 
+                                                          (substring($end-timezone, 5, 2) * $min-s)" />
+                                    <xsl:choose>
+                                       <xsl:when test="starts-with($end-timezone, '-')">
+                                          <xsl:value-of select="$tz" />
+                                       </xsl:when>
+                                       <xsl:when test="starts-with($end-timezone, '+')">
+                                          <xsl:value-of select="$tz * -1" />
+                                       </xsl:when>
+                                       <xsl:otherwise>0</xsl:otherwise>
+                                    </xsl:choose>
+                                 </xsl:variable>
+
+                                 <xsl:variable name="start-secs" select="$start-sec + ($start-min * $min-s) + ($start-hour * $hour-s) + ($start-days * $day-s) + $start-tz-adj" />
+                                 <xsl:variable name="end-secs" select="$end-sec + ($end-min * $min-s) + ($end-hour * $hour-s) + ($end-days * $day-s) + $end-tz-adj" />
+                                 <xsl:variable name="diff-secs" select="$end-secs - $start-secs" />
+                                 <xsl:variable name="s" select="$diff-secs * ((($diff-secs &lt; 0) * -2) + 1)" />
+                                 <xsl:variable name="days" select="floor($s div $day-s)" />
+                                 <xsl:variable name="hours" select="floor(($s - ($days * $day-s)) div $hour-s)" />
+                                 <xsl:variable name="mins" select="floor(($s - ($days * $day-s) - ($hours * $hour-s)) div $min-s)" />
+                                 <xsl:variable name="secs" select="$s - ($days * $day-s) - ($hours * $hour-s) - ($mins * $min-s)" />
+                                 <xsl:if test="$diff-secs &lt; 0">-</xsl:if>
+                                 <xsl:text>P</xsl:text>
+                                 <xsl:if test="$days">
+                                    <xsl:value-of select="$days" />
+                                    <xsl:text>D</xsl:text>
+                                 </xsl:if>
+                                 <xsl:if test="$hours or $mins or $secs">T</xsl:if>
+                                 <xsl:if test="$hours">
+                                    <xsl:value-of select="$hours" />
+                                    <xsl:text>H</xsl:text>
+                                 </xsl:if>
+                                 <xsl:if test="$mins">
+                                    <xsl:value-of select="$mins" />
+                                    <xsl:text>M</xsl:text>
+                                 </xsl:if>
+                                 <xsl:if test="$secs">
+                                    <xsl:value-of select="$secs" />
+                                    <xsl:text>S</xsl:text>
+                                 </xsl:if>
+                              </xsl:if>
+                           </xsl:when>
+                        </xsl:choose>
+                     </xsl:if>
+                  </xsl:when>
+               </xsl:choose>
+            </xsl:when>
+         </xsl:choose>
+      </xsl:if>
+   </xsl:variable>
+   <func:result select="$difference" />   
+</func:function>
+
+</xsl:stylesheet>
Index: /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/base.css
===================================================================
--- /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/base.css (revision 296)
+++ /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/base.css (revision 296)
@@ -0,0 +1,408 @@
+/* box model */
+
+BODY {
+	margin: 1em;
+	}
+
+H1 {
+	padding: 0.3em 0.5em 0.3em 0.5em;
+	margin: 0em;
+	}
+
+H2 {
+	padding: 0.2em 1em 0.2em 0.8em;
+	margin: 1em 0em 0em 0em;
+	}
+
+H3 {
+	padding: 0.1em 1em 0.2em 0.8em;
+	margin: 0em;
+	}
+
+H4 {
+	padding: 0em;
+	margin: 0.5em 1em;
+	}
+
+H5 {
+	padding: 0em;
+	margin: 0em 1em;
+	}
+
+P, TABLE {
+	margin: 0.5em 1em;
+	}
+
+UL, OL {
+	margin: 0.5em 2em;
+	}
+
+UL UL, UL OL, OL UL, OL OL {
+	margin: 0.5em 0em;
+	}
+
+TD.implementations UL {
+	margin: 0.5em 0em;
+	}
+
+TD.implementations LI {
+	margin: 0em 2em;
+	}
+
+LI {
+	margin: 0.5em 2em;
+	list-style-type: disc;
+	}
+
+LI P {
+	margin: 0em;
+	}
+
+DL {
+	margin: 0.5em 2em 1em 2em;
+	}
+
+DT {
+	margin: 1em;
+	clear: both;
+	}
+
+DD {
+	margin: -0.5em 0em -0.5em 2em;
+	}
+
+DD UL, DD OL {
+	margin-left: 0em;
+	}
+
+BLOCKQUOTE {
+	margin-left: 3em;
+	}
+
+IMG {
+	position: relative;
+	}
+
+TABLE {
+	width: 100%;
+	margin: 0em;
+	}
+
+PRE {
+	padding: 0.5em 3em 0.5em 3em;
+	margin: 0em;
+	}
+
+#content TD PRE {
+	padding: 0em;
+	}
+
+PRE.copyright {
+	padding: 0em;
+	margin: 0em;
+	}
+
+.issue {
+	padding: 0em 3em;
+	margin: 0em;
+	}
+
+#menu {
+	width: 20%;
+	padding: 0em;
+	}
+
+P.level1, P.level2, P.level3, P.level4 {
+	padding: 0em 1em;
+	margin: 0em;
+	}
+
+P.level1 {
+	margin: 0em 0em 3px 0em;
+	}
+
+P.level2 {
+	margin: 0em 0em 1px 0em;
+	}
+
+P.level3 {
+	margin-left: 1em;
+	}
+
+P.level4 {
+	margin-left: 2em;
+	}
+
+#content TH, #content TD {
+	margin: 0em;
+	padding: 0em 0.5em;
+	}
+
+#navigation, #content, #colophon P {
+	margin-top: 2px;
+	}
+
+TD.implementations {
+	width: 25%;
+	}
+
+/* fonts */
+BODY, TR {
+	font-family: 'Trebuchet MS', Arial, sans-serif;
+	}
+
+H1, H2, H3, H4, H5, H6 {
+	font-family: 'Trebuchet MS', Arial, sans-serif;
+	}
+
+H1 {
+	font-size: 173%;
+	font-weight: bold;
+	}
+
+H2 {
+	font-size: 120%;
+	font-weight: bold;
+	}
+
+H3 {
+	font-size: 120%;
+	font-weight: bold;
+	}
+
+H4 {
+	font-size: 100%;
+	font-weight: bold;
+	}
+
+H5 {
+	font-size: 100%
+	font-weight: normal;
+	font-style: italic;
+	}
+
+#navigation TD {
+	font-weight: bold;
+	}
+
+DT {
+	font-weight: bold;
+	}
+
+PRE, CODE {
+	font-size: 100%;
+	}
+
+A:link, A:visited, A:active, A:hover {
+	font-weight: bold;
+	}
+
+A.offsite:link, A.offsite:visited, A.offsite:active, A.offsite:hover {
+	font-weight: normal;
+	}
+
+#menu P.level1, P.level1 A:link, P.level1 A:visited, P.level1 A:hover {
+	font-weight: bold;
+	}
+
+#menu P.level2, P.level2 A:link, P.level2 A:visited {
+	font-weight: normal;
+	}
+
+#menu P.level3, P.level3 A:link, P.level3 A:visited {
+	font-weight: normal;
+	}
+
+#menu P.level3, #menu P.level4 {
+    font-size: 83%;
+	}
+
+#menu P.level4, P.level4 A:link, P.level4 A:visited {
+	font-weight: normal;
+	font-style: italic;
+	}
+
+.note {
+	font-family: 'Trebuchet MS', Arial, sans-serif;
+	font-size: 100%;
+	font-style: italic;
+	}
+
+#colophon {
+	font-size: 69%;
+	}
+
+/* colours */
+BODY {
+	background: white;
+	color: black;
+	border: 0px none white;
+	}
+
+/* this is to make Navigator fill the entire line */
+H1, #content {
+	border: 1px solid white;
+	width: 100%;
+	}
+
+H1, H1 A:link, H1 A:visited, H1 A:active, H1 A:hover {
+    background: #401;
+	color: white;
+	}
+
+H2 {
+	border-top: 5px solid white;
+	width: 100%;
+	}
+
+H2, H2 A:link, H2 A:visited, H2 A:active, H2 A:hover {
+	background: #041;
+	color: white;
+	}
+
+
+H3 {
+	border-top: 3px solid white;
+	width: 100%;
+	}
+
+H3, H3 A:link, H3 A:visited, H3 A:active, H3 A:hover {
+	color: #041;
+	background: #EFE;
+	}
+
+#content TABLE {
+	border-collapse: collapse;
+	}
+
+#content TH {
+	background: #041;
+	color: white;
+	}
+
+#content TD {
+	background: #EFE;
+	color: black;
+    border: 1px solid #041;
+	}
+
+#content, #navigation {
+	background: #EFE;
+	color: black;
+	}
+
+HR {
+	color: #041;
+	background: #041;
+	}
+
+IMG, A:link IMG, A:visited IMG, A:hover IMG, A:active IMG {
+	border: 0px none white;
+	background: transparent;
+	}
+
+A:link, A:visited, A:active, A:hover {
+	color: #052;
+	background: transparent;
+	border: 0px none white;
+	}
+
+.note {
+	color: #333;
+	}
+
+.note A:link, .note A:visited, .note A:hover {
+    background: transparent;
+	color: #041;
+	}
+
+.error {
+	color: #C00;
+	}
+
+#colophon {
+	color: #333;
+	background: #FEE;
+	}
+
+#colophon A:link, #colophon A:visited, #colophon A:hover {
+	color: #401;
+	background: transparent;
+	}
+
+TD.implementations {
+	border-left: 1px solid #041;
+	}
+
+#menu {
+	background: #EEF;
+	color: #014;
+	}
+
+#menu P.level1, P.level1 A:link, P.level1 A:visited, P.level1 A:active P.level1 A:hover {
+	background: #014;
+	color: white;
+	}
+
+#menu P.level2, P.level2 A:link, P.level2 A:visited, P.level2 A:active P.level2 A:hover, 
+#menu P.level3, P.level3 A:link, P.level3 A:visited, P.level3 A:active P.level3 A:hover, 
+#menu P.level4, P.level4 A:link, P.level4 A:visited, P.level4 A:active P.level4 A:hover {
+	background: #EEF;
+	color: #014;
+	}
+
+
+P.level2 A:hover, P.level3 A:hover, P.level4 A:hover {
+	text-decoration: underline;
+	}
+
+
+/* text */
+OL OL LI {
+	list-style: lower-alpha;
+	}
+
+TH {
+	text-align: left;
+	}
+
+TD {
+	vertical-align: top;
+	}
+
+#content TH, #content TD {
+	text-align: center;
+	}
+
+#content TH.rowhead, #content TD.rowhead {
+	text-align: left;
+	}
+
+H1 {
+	text-transform: uppercase;
+	}
+
+H2 {
+	text-transform: uppercase;
+	}
+
+H4 {
+	text-transform: lowercase;
+	}
+
+#menu {
+	text-transform: lowercase;
+	}
+
+#navigation TD {
+	text-transform: uppercase;
+	text-align: center;
+	}
+
+A.offsite {
+    text-decoration: underline;
+	}
+
+A, A.function, A.element {
+	text-decoration: none;
+	}
Index: /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.difference.template.xsl
===================================================================
--- /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.difference.template.xsl (revision 296)
+++ /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.difference.template.xsl (revision 296)
@@ -0,0 +1,263 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:date="http://exslt.org/dates-and-times"
+                extension-element-prefixes="date">
+
+<date:month-lengths>
+   <date:month>31</date:month>
+   <date:month>28</date:month>
+   <date:month>31</date:month>
+   <date:month>30</date:month>
+   <date:month>31</date:month>
+   <date:month>30</date:month>
+   <date:month>31</date:month>
+   <date:month>31</date:month>
+   <date:month>30</date:month>
+   <date:month>31</date:month>
+   <date:month>30</date:month>
+   <date:month>31</date:month>
+</date:month-lengths>
+
+<xsl:template name="date:difference">
+   <xsl:param name="start" />
+   <xsl:param name="end" />
+
+   <xsl:variable name="start-neg" select="starts-with($start, '-')" />
+   <xsl:variable name="start-no-neg">
+      <xsl:choose>
+         <xsl:when test="$start-neg or starts-with($start, '+')">
+            <xsl:value-of select="substring($start, 2)" />
+         </xsl:when>
+         <xsl:otherwise>
+            <xsl:value-of select="$start" />
+         </xsl:otherwise>
+      </xsl:choose>
+   </xsl:variable>
+   <xsl:variable name="start-no-neg-length" select="string-length($start-no-neg)" />
+   <xsl:variable name="start-timezone">
+      <xsl:choose>
+         <xsl:when test="substring($start-no-neg, $start-no-neg-length) = 'Z'">Z</xsl:when>
+         <xsl:otherwise>
+            <xsl:variable name="tz" select="substring($start-no-neg, $start-no-neg-length - 5)" />
+            <xsl:if test="(substring($tz, 1, 1) = '-' or 
+                           substring($tz, 1, 1) = '+') and
+                          substring($tz, 4, 1) = ':'">
+               <xsl:value-of select="$tz" />
+            </xsl:if>
+         </xsl:otherwise>
+      </xsl:choose>
+   </xsl:variable>
+   <xsl:variable name="end-neg" select="starts-with($end, '-')" />
+   <xsl:variable name="end-no-neg">
+      <xsl:choose>
+         <xsl:when test="$end-neg or starts-with($end, '+')">
+            <xsl:value-of select="substring($end, 2)" />
+         </xsl:when>
+         <xsl:otherwise>
+            <xsl:value-of select="$end" />
+         </xsl:otherwise>
+      </xsl:choose>
+   </xsl:variable>
+   <xsl:variable name="end-no-neg-length" select="string-length($end-no-neg)" />
+   <xsl:variable name="end-timezone">
+      <xsl:choose>
+         <xsl:when test="substring($end-no-neg, $end-no-neg-length) = 'Z'">Z</xsl:when>
+         <xsl:otherwise>
+            <xsl:variable name="tz" select="substring($end-no-neg, $end-no-neg-length - 5)" />
+            <xsl:if test="(substring($tz, 1, 1) = '-' or 
+                           substring($tz, 1, 1) = '+') and
+                          substring($tz, 4, 1) = ':'">
+               <xsl:value-of select="$tz" />
+            </xsl:if>
+         </xsl:otherwise>
+      </xsl:choose>
+   </xsl:variable>
+
+   <xsl:variable name="difference">
+      <xsl:if test="(not(string($start-timezone)) or
+                     $start-timezone = 'Z' or 
+                     (substring($start-timezone, 2, 2) &lt;= 23 and
+                      substring($start-timezone, 5, 2) &lt;= 59)) and
+                    (not(string($end-timezone)) or
+                     $end-timezone = 'Z' or 
+                     (substring($end-timezone, 2, 2) &lt;= 23 and
+                      substring($end-timezone, 5, 2) &lt;= 59))">
+         <xsl:variable name="start-dt" select="substring($start-no-neg, 1, $start-no-neg-length - string-length($start-timezone))" />
+         <xsl:variable name="start-dt-length" select="string-length($start-dt)" />
+         <xsl:variable name="end-dt" select="substring($end-no-neg, 1, $end-no-neg-length - string-length($end-timezone))" />
+         <xsl:variable name="end-dt-length" select="string-length($end-dt)" />
+
+         <xsl:variable name="start-year" select="substring($start-dt, 1, 4) * (($start-neg * -2) + 1)" />
+         <xsl:variable name="end-year" select="substring($end-dt, 1, 4) * (($end-neg * -2) + 1)" />
+         <xsl:variable name="diff-year" select="$end-year - $start-year" />
+         <xsl:choose>
+            <xsl:when test="not(number($start-year) and number($end-year))" />
+            <xsl:when test="$start-dt-length = 4 or $end-dt-length = 4">
+               <xsl:choose>
+                  <xsl:when test="$diff-year &lt; 0">-P<xsl:value-of select="$diff-year * -1" />Y</xsl:when>
+                  <xsl:otherwise>P<xsl:value-of select="$diff-year" />Y</xsl:otherwise>
+               </xsl:choose>
+            </xsl:when>
+            <xsl:when test="substring($start-dt, 5, 1) = '-' and 
+                            substring($end-dt, 5, 1) = '-'">
+               <xsl:variable name="start-month" select="substring($start-dt, 6, 2)" />
+               <xsl:variable name="end-month" select="substring($end-dt, 6, 2)" />
+               <xsl:variable name="diff-month" select="$end-month - $start-month" />
+               <xsl:choose>
+                  <xsl:when test="not($start-month &lt;= 12 and $end-month &lt;= 12)" />
+                  <xsl:when test="$start-dt-length = 7 or $end-dt-length = 7">
+                     <xsl:variable name="months" select="$diff-month + ($diff-year * 12)" />
+                     <xsl:variable name="abs-months" select="$months * ((($months >= 0) * 2) - 1)" />
+                     <xsl:variable name="y" select="floor($abs-months div 12)" />
+                     <xsl:variable name="m" select="$abs-months mod 12" />
+                     <xsl:if test="$months &lt; 0">-</xsl:if>
+                     <xsl:text>P</xsl:text>
+                     <xsl:if test="$y"><xsl:value-of select="$y" />Y</xsl:if>
+                     <xsl:if test="$m"><xsl:value-of select="$m" />M</xsl:if>
+                  </xsl:when>
+                  <xsl:when test="substring($start-dt, 8, 1) = '-' and
+                                  substring($end-dt, 8, 1) = '-'">
+                     <xsl:variable name="start-day" select="substring($start-dt, 9, 2)" />
+                     <xsl:variable name="end-day" select="substring($end-dt, 9, 2)" />
+                     <xsl:if test="$start-day &lt;= 31 and $end-day &lt;= 31">
+                        <xsl:variable name="month-lengths" select="document('')/*/date:month-lengths/date:month" />
+                        <xsl:variable name="start-y-1" select="$start-year - 1" />
+                        <xsl:variable name="start-leaps" 
+                                      select="floor($start-y-1 div 4) -
+                                              floor($start-y-1 div 100) +
+                                              floor($start-y-1 div 400)" />
+                        <xsl:variable name="start-leap" select="(not($start-year mod 4) and $start-year mod 100) or not($start-year mod 400)" />
+                        <xsl:variable name="start-month-days" 
+                                      select="sum($month-lengths[position() &lt; $start-month])" />
+                        <xsl:variable name="start-days">
+                           <xsl:variable name="days" 
+                                         select="($start-year * 365) + $start-leaps +
+                                                 $start-month-days + $start-day" />
+                           <xsl:choose>
+                              <xsl:when test="$start-leap">
+                                 <xsl:value-of select="$days + 1" />
+                              </xsl:when>
+                              <xsl:otherwise>
+                                 <xsl:value-of select="$days" />
+                              </xsl:otherwise>
+                           </xsl:choose>
+                        </xsl:variable>
+                        <xsl:variable name="end-y-1" select="$end-year - 1" />
+                        <xsl:variable name="end-leaps" 
+                                      select="floor($end-y-1 div 4) -
+                                              floor($end-y-1 div 100) +
+                                              floor($end-y-1 div 400)" />
+                        <xsl:variable name="end-leap" select="(not($end-year mod 4) and $end-year mod 100) or not($end-year mod 400)" />
+                        <xsl:variable name="end-month-days" 
+                                      select="sum($month-lengths[position() &lt; $end-month])" />
+                        <xsl:variable name="end-days">
+                           <xsl:variable name="days" 
+                                         select="($end-year * 365) + $end-leaps +
+                                                 $end-month-days + $end-day" />
+                           <xsl:choose>
+                              <xsl:when test="$end-leap">
+                                 <xsl:value-of select="$days + 1" />
+                              </xsl:when>
+                              <xsl:otherwise>
+                                 <xsl:value-of select="$days" />
+                              </xsl:otherwise>
+                           </xsl:choose>
+                        </xsl:variable>
+                        <xsl:variable name="diff-days" select="$end-days - $start-days" />
+                        <xsl:choose>
+                           <xsl:when test="$start-dt-length = 10 or $end-dt-length = 10">
+                              <xsl:choose>
+                                 <xsl:when test="$diff-days &lt; 0">-P<xsl:value-of select="$diff-days * -1" />D</xsl:when>
+                                 <xsl:otherwise>P<xsl:value-of select="$diff-days" />D</xsl:otherwise>
+                              </xsl:choose>
+                           </xsl:when>
+                           <xsl:when test="substring($start-dt, 11, 1) = 'T' and
+                                           substring($end-dt, 11, 1) = 'T' and
+                                           substring($start-dt, 14, 1) = ':' and
+                                           substring($start-dt, 17, 1) = ':' and
+                                           substring($end-dt, 14, 1) = ':' and
+                                           substring($end-dt, 17, 1) = ':'">
+                              <xsl:variable name="start-hour" select="substring($start-dt, 12, 2)" />
+                              <xsl:variable name="start-min" select="substring($start-dt, 15, 2)" />
+                              <xsl:variable name="start-sec" select="substring($start-dt, 18)" />
+                              <xsl:variable name="end-hour" select="substring($end-dt, 12, 2)" />
+                              <xsl:variable name="end-min" select="substring($end-dt, 15, 2)" />
+                              <xsl:variable name="end-sec" select="substring($end-dt, 18)" />
+                              <xsl:if test="$start-hour &lt;= 23 and $end-hour &lt;= 23 and
+                                            $start-min &lt;= 59 and $end-min &lt;= 59 and
+                                            $start-sec &lt;= 60 and $end-sec &lt;= 60">
+                                 <xsl:variable name="min-s" select="60" />
+                                 <xsl:variable name="hour-s" select="60 * 60" />
+                                 <xsl:variable name="day-s" select="60 * 60 * 24" />
+
+                                 <xsl:variable name="start-tz-adj">
+                                    <xsl:variable name="tz" 
+                                                  select="(substring($start-timezone, 2, 2) * $hour-s) + 
+                                                          (substring($start-timezone, 5, 2) * $min-s)" />
+                                    <xsl:choose>
+                                       <xsl:when test="starts-with($start-timezone, '-')">
+                                          <xsl:value-of select="$tz" />
+                                       </xsl:when>
+                                       <xsl:when test="starts-with($start-timezone, '+')">
+                                          <xsl:value-of select="$tz * -1" />
+                                       </xsl:when>
+                                       <xsl:otherwise>0</xsl:otherwise>
+                                    </xsl:choose>
+                                 </xsl:variable>
+                                 <xsl:variable name="end-tz-adj">
+                                    <xsl:variable name="tz" 
+                                                  select="(substring($end-timezone, 2, 2) * $hour-s) + 
+                                                          (substring($end-timezone, 5, 2) * $min-s)" />
+                                    <xsl:choose>
+                                       <xsl:when test="starts-with($end-timezone, '-')">
+                                          <xsl:value-of select="$tz" />
+                                       </xsl:when>
+                                       <xsl:when test="starts-with($end-timezone, '+')">
+                                          <xsl:value-of select="$tz * -1" />
+                                       </xsl:when>
+                                       <xsl:otherwise>0</xsl:otherwise>
+                                    </xsl:choose>
+                                 </xsl:variable>
+
+                                 <xsl:variable name="start-secs" select="$start-sec + ($start-min * $min-s) + ($start-hour * $hour-s) + ($start-days * $day-s) + $start-tz-adj" />
+                                 <xsl:variable name="end-secs" select="$end-sec + ($end-min * $min-s) + ($end-hour * $hour-s) + ($end-days * $day-s) + $end-tz-adj" />
+                                 <xsl:variable name="diff-secs" select="$end-secs - $start-secs" />
+                                 <xsl:variable name="s" select="$diff-secs * ((($diff-secs &lt; 0) * -2) + 1)" />
+                                 <xsl:variable name="days" select="floor($s div $day-s)" />
+                                 <xsl:variable name="hours" select="floor(($s - ($days * $day-s)) div $hour-s)" />
+                                 <xsl:variable name="mins" select="floor(($s - ($days * $day-s) - ($hours * $hour-s)) div $min-s)" />
+                                 <xsl:variable name="secs" select="$s - ($days * $day-s) - ($hours * $hour-s) - ($mins * $min-s)" />
+                                 <xsl:if test="$diff-secs &lt; 0">-</xsl:if>
+                                 <xsl:text>P</xsl:text>
+                                 <xsl:if test="$days">
+                                    <xsl:value-of select="$days" />
+                                    <xsl:text>D</xsl:text>
+                                 </xsl:if>
+                                 <xsl:if test="$hours or $mins or $secs">T</xsl:if>
+                                 <xsl:if test="$hours">
+                                    <xsl:value-of select="$hours" />
+                                    <xsl:text>H</xsl:text>
+                                 </xsl:if>
+                                 <xsl:if test="$mins">
+                                    <xsl:value-of select="$mins" />
+                                    <xsl:text>M</xsl:text>
+                                 </xsl:if>
+                                 <xsl:if test="$secs">
+                                    <xsl:value-of select="$secs" />
+                                    <xsl:text>S</xsl:text>
+                                 </xsl:if>
+                              </xsl:if>
+                           </xsl:when>
+                        </xsl:choose>
+                     </xsl:if>
+                  </xsl:when>
+               </xsl:choose>
+            </xsl:when>
+         </xsl:choose>
+      </xsl:if>
+   </xsl:variable>
+   <xsl:value-of select="$difference" />   
+</xsl:template>
+
+</xsl:stylesheet>
Index: /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.difference.xml
===================================================================
--- /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.difference.xml (revision 296)
+++ /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.difference.xml (revision 296)
@@ -0,0 +1,211 @@
+<?xml version="1.0"?>
+<exslt:function xmlns:exslt="http://exslt.org/documentation" 
+               version="1" module="date" status="implemented">
+
+<exslt:name>difference</exslt:name>
+
+<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+                 xmlns:dc="http://purl.org/dc/elements/1.1/"
+                 ID="date:difference">
+   <dc:subject>EXSLT</dc:subject>
+   <dc:subject>date</dc:subject>
+   <dc:subject>difference</dc:subject>
+   <exslt:revision>
+      <rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+                       xmlns:dc="http://purl.org/dc/elements/1.1/"
+                       ID="date:difference.1">
+         <exslt:version>1</exslt:version>
+         <dc:creator email="mail@jenitennison.com" 
+                     url="http://www.jenitennison.com/">
+            Jeni Tennison
+         </dc:creator>
+         <dc:date>2001-05-12</dc:date>
+         <dc:description xmlns="http://www.w3.org/1999/xhtml">
+            Returns the difference between two dates as a duration.
+         </dc:description>
+      </rdf:Description>
+   </exslt:revision>
+   <exslt:revision>
+      <rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+                       xmlns:dc="http://purl.org/dc/elements/1.1/"
+                       ID="date:difference.1.1">
+         <exslt:version>1.1</exslt:version>
+         <dc:creator email="mail@jenitennison.com" 
+                     url="http://www.jenitennison.com/">
+            Jeni Tennison
+         </dc:creator>
+         <dc:date>2001-06-11</dc:date>
+         <dc:description xmlns="http://www.w3.org/1999/xhtml">
+            Added implementations in Javascript, XSLT and EXSLT - Functions.
+         </dc:description>
+      </rdf:Description>
+   </exslt:revision>
+   <exslt:revision>
+      <rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+                       xmlns:dc="http://purl.org/dc/elements/1.1/"
+                       ID="date:difference.1.2">
+         <exslt:version>1.2</exslt:version>
+         <dc:creator email="mail@jenitennison.com" 
+                     url="http://www.jenitennison.com/">
+            Jeni Tennison
+         </dc:creator>
+         <dc:date>2001-06-16</dc:date>
+         <dc:description xmlns="http://www.w3.org/1999/xhtml">
+            <ul>
+               <li>Updated Javascript implementation.</li>
+               <li>Added Microsoft-specific stylesheet.</li>
+            </ul>
+         </dc:description>
+      </rdf:Description>
+   </exslt:revision>
+   <exslt:revision>
+      <rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+                       xmlns:dc="http://purl.org/dc/elements/1.1/"
+                       ID="date:difference.1.3">
+         <exslt:version>1.3</exslt:version>
+         <dc:creator email="craig.stewart@nottingham.ac.uk" 
+                     url="">Craig Stewart</dc:creator>
+         <dc:date>2002-08-21</dc:date>
+         <dc:description xmlns="http://www.w3.org/1999/xhtml">Added 4XSLT and libxslt implementation to the list.</dc:description>
+      </rdf:Description>
+   </exslt:revision>
+   <exslt:revision>
+      <rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+                       xmlns:dc="http://purl.org/dc/elements/1.1/"
+                       ID="date:difference.1.4">
+         <exslt:version>1.4</exslt:version>
+         <dc:creator email="craig.stewart@nottingham.ac.uk" 
+                     url="">Craig Stewart</dc:creator>
+         <dc:date>2002-11-12</dc:date>
+         <dc:description xmlns="http://www.w3.org/1999/xhtml">Updated 4XSLT version to 0.12.0a3.</dc:description>
+      </rdf:Description>
+   </exslt:revision>
+</rdf:Description>
+
+<exslt:doc xmlns:html="http://www.w3.org/1999/xhtml"
+           xmlns="">
+   <html:div xmlns="http://www.w3.org/1999/xhtml">
+      <p>
+         The <code>date:difference</code> function returns the duration between the first date and the second date.  If the first date occurs before the second date, then the result is a positive duration; if it occurs after the second date, the result is a negative duration.
+      </p>
+      <p>
+         The two dates must both be right-truncated date/time strings in one of the formats defined in [<a href="http://www.w3.org/TR/xmlschema-2/" class="offsite">XML Schema Part 2: Datatypes</a>].  The date/time with the most specific format (i.e. the least truncation) is converted into the same format as the date with the most specific format (i.e. the most truncation).  The permitted formats are as follows, from most specific to least specific:
+      </p>
+      <ul>
+         <li>
+            <a href="http://www.w3.org/TR/xmlschema-2/#dateTime" class="offsite"><code>xs:dateTime</code></a> (<code><var>CCYY</var>-<var>MM</var>-<var>DD</var>T<var>hh</var>:<var>mm</var>:<var>ss</var></code>)
+         </li>
+         <li>
+            <a href="http://www.w3.org/TR/xmlschema-2/#date" class="offsite"><code>xs:date</code></a> (<code><var>CCYY</var>-<var>MM</var>-<var>DD</var></code>)
+         </li>
+         <li>
+            <a href="http://www.w3.org/TR/xmlschema-2/#gYearMonth" class="offsite"><code>xs:gYearMonth</code></a> (<code><var>CCYY</var>-<var>MM</var></code>)
+         </li>
+         <li>
+            <a href="http://www.w3.org/TR/xmlschema-2/#gYear" class="offsite"><code>xs:gYear</code></a> (<code><var>CCYY</var></code>)
+         </li>
+      </ul>
+      <p>
+         If either of the arguments is not in one of these formats, <code>date:difference</code> returns the empty string (<code>''</code>).
+      </p>
+      <p>
+         The difference between the date/times is returned as a string in the format defined for <code>xs:duration</code> in [<a href="http://www.w3.org/TR/xmlschema-2/#duration" class="offsite">3.2.6 duration</a>] of [<a href="http://www.w3.org/TR/xmlschema-2/" class="offsite">XML Schema Part 2: Datatypes</a>].
+      </p>
+      <p>
+         If the date/time string with the least specific format is in either <code>xs:gYearMonth</code> or <code>xs:gYear</code> format, then the number of days, hours, minutes and seconds in the duration string must be equal to zero.  (The format of the string will be <code>P<var>n</var>Y<var>n</var>M</code>.)  The number of months specified in the duration must be less than 12.
+      </p>
+      <p>
+         Otherwise, the number of years and months in the duration string must be equal to zero.  (The format of the string will be <code>P<var>n</var>DT<var>n</var>H<var>n</var>M<var>n</var>S</code>.)  The number of seconds specified in the duration string must be less than 60; the number of minutes must be less than 60; the number of hours must be less than 24.
+      </p>
+   </html:div>
+</exslt:doc>
+
+<exslt:definition xmlns:xs="http://www.w3.org/2001/XMLSchema">
+   <exslt:return type="string" />
+   <exslt:arg name="start" type="string" 
+              optional="no" />
+   <exslt:arg name="end" type="string" 
+              optional="no" />
+</exslt:definition>
+
+<exslt:implementations>
+   <exslt:vendor-implementation
+           version="1"
+           vendor="4XSLT, from 4Suite."
+           vendor-url="http://4Suite.org"
+           vendor-version="0.12.0a3" />
+   <exslt:vendor-implementation
+           version="1"
+           vendor="libxslt from Daniel Veillard et al."
+           vendor-url="http://xmlsoft.org/XSLT/"
+           vendor-version="1.0.19" />
+   <exslt:implementation src="date.difference.function.xsl" language="exslt:exslt" 
+                         version="1" />
+   <exslt:implementation src="date.difference.template.xsl" language="exslt:xslt" 
+                         version="1" />
+   <exslt:implementation src="date.js" language="exslt:javascript" 
+                         version="1">
+      <rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+                       xmlns:dc="http://purl.org/dc/elements/1.1/"
+                       ID="date:difference.js">
+         <dc:subject>EXSLT</dc:subject>
+         <dc:subject>date</dc:subject>
+         <dc:subject>difference</dc:subject>
+         <dc:subject>Javascript</dc:subject>
+         <exslt:revision>
+            <rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+                             xmlns:dc="http://purl.org/dc/elements/1.1/"
+                             ID="date:difference.js.1">
+               <exslt:version>1</exslt:version>
+               <dc:creator xmlns:vcf="http://www.ietf.org/internet-drafts/draft-dawson-vcard-xml-dtd-03.txt" rdf:parseType="Resource">
+                  <vcf:fn>Chris Bayes</vcf:fn>
+                  <vcf:email>chris@bayes.co.uk</vcf:email>
+                  <vcf:url>http://www.bayes.co.uk</vcf:url>
+               </dc:creator>
+               <dc:date>2001-06-11</dc:date>
+            </rdf:Description>
+         </exslt:revision>
+         <exslt:revision>
+            <rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+                             xmlns:dc="http://purl.org/dc/elements/1.1/"
+                             ID="date:difference.js.2">
+               <exslt:version>2</exslt:version>
+               <dc:creator xmlns:vcf="http://www.ietf.org/internet-drafts/draft-dawson-vcard-xml-dtd-03.txt" rdf:parseType="Resource">
+                  <vcf:fn>Chris Bayes</vcf:fn>
+                  <vcf:email>chris@bayes.co.uk</vcf:email>
+                  <vcf:url>http://www.bayes.co.uk</vcf:url>
+               </dc:creator>
+               <dc:date>2001-06-16</dc:date>
+            </rdf:Description>
+         </exslt:revision>
+      </rdf:Description>
+   </exslt:implementation>
+   <exslt:implementation src="date.msxsl.xsl" language="exslt:msxsl"
+                         version="1">
+      <rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+                       xmlns:dc="http://purl.org/dc/elements/1.1/"
+                       ID="date:difference.msxsl">
+         <dc:subject>EXSLT</dc:subject>
+         <dc:subject>date</dc:subject>
+         <dc:subject>difference</dc:subject>
+         <dc:subject>MSXML</dc:subject>
+         <exslt:revision>
+            <rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+                             xmlns:dc="http://purl.org/dc/elements/1.1/"
+                             ID="date:difference.msxsl.1">
+               <exslt:version>1</exslt:version>
+               <dc:creator xmlns:vcf="http://www.ietf.org/internet-drafts/draft-dawson-vcard-xml-dtd-03.txt" rdf:parseType="Resource">
+                  <vcf:fn>Chris Bayes</vcf:fn>
+                  <vcf:email>chris@bayes.co.uk</vcf:email>
+                  <vcf:url>http://www.bayes.co.uk</vcf:url>
+               </dc:creator>
+               <dc:date>2001-06-16</dc:date>
+            </rdf:Description>
+         </exslt:revision>
+      </rdf:Description>
+   </exslt:implementation>
+</exslt:implementations>
+
+<exslt:use-cases />
+
+</exslt:function>
Index: /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.msxsl.xsl
===================================================================
--- /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.msxsl.xsl (revision 296)
+++ /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.msxsl.xsl (revision 296)
@@ -0,0 +1,1270 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:date="http://exslt.org/dates-and-times"
+                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
+                extension-element-prefixes="date msxsl">
+
+<msxsl:script language="Javascript" implements-prefix="date">
+<![CDATA[
+/**
+<doc:module date="2001-06-12">
+   <doc:module>exslt:date-time</doc:module>
+   <doc:name>dates</doc:name>
+   <doc:version>2.0</doc:version>
+   <doc:language>exslt:javascript</doc:language>
+   <doc:meta>
+      <doc:author email="chris@bayes.co.uk" url="http://www.bayes.co.uk">Chris Bayes</doc:author>
+      <doc:summary>Implementation of EXSLT - Dates (http://www.exslt.org/date)</doc:summary>
+      <doc:todo>_validDuration is not 100%</doc:todo>
+      <doc:todo>All timezone code.</doc:todo>
+   </doc:meta>
+</doc:module>
+**/
+var gsSuppliedFormat = "";
+var gsLang = "en";
+var gaLang = new Array();
+// en 
+gaLang["en"] = new Array();
+gaLang["en"]["months"] = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
+gaLang["en"]["shortMonths"] = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
+gaLang["en"]["days"] = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
+gaLang["en"]["shortDays"] = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
+
+
+var gaDayNames = new Array();
+gaDayNames["sunday"] = 0;gaDayNames["monday"] = 1;gaDayNames["tuesday"] = 2;gaDayNames["wednesday"] = 3;gaDayNames["thursday"] = 4;gaDayNames["friday"] = 5;gaDayNames["saturday"] = 6;
+var gaMonthCnt = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
+var gaMonthCntL = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
+function _isLeap(y){return ( ((y%4==0)&(y%100!=0))|(y%400==0) );}
+function _dayOfWeek(y,d){return ( ((y-1)+Math.floor((y-1)/4)-Math.floor((y-1)/100)+Math.floor((y-1)/400)+d)%7);}
+function _dayInYear(y,m,d){return (m==0?d:eval( (_isLeap(y)?gaMonthCntL.slice(0,m).join("+"):gaMonthCnt.slice(0,m).join("+")) )+(d*1) );}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>add</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="no"></doc:arg>
+		<doc:arg name="duration" type="string" default="''" optional="no"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function add(){//
+	var d1,d2;
+	if (((d1 = _validDate(arguments[0], "xs:dateTime")) ||
+		 (d1 = _validDate(arguments[0], "xs:date")) ||
+		 (d1 = _validDate(arguments[0], "xs:gYearMonth")) ||
+		 (d1 = _validDate(arguments[0], "xs:gYear"))
+		) && 
+		(d2 = _validDuration(arguments[1])))
+		return _formatDate(d2.addDate(d1), gsSuppliedFormat);
+	return '';
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>addDuration</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="duration" type="string" default="''" optional="no"></doc:arg>
+		<doc:arg name="duration" type="string" default="''" optional="no"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function addDuration(duration1, duration2){
+	if ((d1 = _validDuration(duration1)) && (d2 = _validDuration(duration2))){
+		var d1mnth = d1.years *12 + d1.months;
+		var d1secs = d1.days*86400 + d1.hours*3600 + d1.minutes*60 + (d1.seconds+'.'+d1.fraction)*1;
+		var d2mnth = d2.years *12 + d2.months;
+		var d2secs = d2.days*86400 + d2.hours*3600 + d2.minutes*60 + (d2.seconds+'.'+d2.fraction)*1;
+		var mnthdiff = (d1.pm+d1mnth)*1 + (d2.pm+d2mnth)*1;
+		var secsdiff = (d1.pm+d1secs)*1 + (d2.pm+d2secs)*1;
+		if ((mnthdiff < 0 && secsdiff > 0) || (mnthdiff > 0 && secsdiff < 0))
+			return '';
+		var secs = secsdiff % 60;
+		var pm = (mnthdiff<0||secsdiff<0?'-':'');
+		mnthdiff = Math.abs(mnthdiff);
+		secsdiff = Math.abs(secsdiff);
+		return _formatDuration(new Duration(pm, 0, mnthdiff, Math.floor(secsdiff/86400), Math.floor((secsdiff%86400)/3600), Math.floor((secsdiff%3600)/60), Math.floor(secs), Math.floor(secs%1)));
+	}
+	return '';
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>date</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function date(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date"))
+			)
+			return _formatDate(oDate, "xs:date");
+		else
+			return '';
+	}else
+		return _formatDate(new Date(), "xs:date");
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>dateTime</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args />
+</doc:function>
+**/
+function dateTime(){//must be UTC/Z
+	if (arguments.length > 0)
+		dateTime_invalidArgument.error;
+	var oDate = new Date();
+	return _formatDate(oDate, "xs:dateTime");
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>dayAbbreviation</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function dayAbbreviation(){
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+		    (oDate = _validDate(arguments[0], "xs:date"))
+		   )
+			return _dayAbbreviation(oDate.getDay(), arguments[1], arguments[2]);
+		else
+			return '';
+	}else
+		return _dayAbbreviation(new Date().getDay(), arguments[1], arguments[2]);
+}
+function _dayAbbreviation(num, dfName, ctx){
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectNodes(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/*[local-name()='days' and namespace-uri()='http://exslt.org/dates-and-times']" +
+			"/*[local-name()='day' and namespace-uri()='http://exslt.org/dates-and-times']/@abbr");
+		if (nodes != null)
+			return nodes[num].nodeValue;
+		else
+			return '';
+	}else{ //we could try local
+		return gaLang[gsLang]["shortDays"][num*1];
+	}
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>dayInMonth</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function dayInMonth(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date")) ||
+			(oDate = _validDate(arguments[0], "xs:gMonthDay")) ||
+			(oDate = _validDate(arguments[0], "xs:gDay"))
+		    )
+			return oDate.getDate();
+		else
+			return Number.NaN
+	}else
+		return new Date().getDate();
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>dayInWeek</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function dayInWeek(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+		    (oDate = _validDate(arguments[0], "xs:date"))
+		   )
+			return _dayInWeek(oDate, arguments[1], arguments[2]);
+		else
+			return Number.NaN;
+	}else
+		return _dayInWeek(new Date(), arguments[1], arguments[2]);
+}
+function _dayInWeek(oDate, dfName, ctx){
+	var fdow = 0;
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectSingleNode(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/@first-day-of-week");
+		if (nodes != null)
+			fdow = gaDayNames[nodes.nodeValue];
+	}
+	return (oDate.getDay()-fdow<0?oDate.getDay()-fdow+7:oDate.getDay()-fdow)+1;
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>dayInYear</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function dayInYear(){
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date"))
+			)
+			return _dayInYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate());
+		else
+			return Number.NaN;
+	}else{
+		var oDate = new Date()
+		return _dayInYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate());
+	}
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>dayName</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function dayName(){
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+		    (oDate = _validDate(arguments[0], "xs:date"))
+		   )
+			return _dayName(oDate.getDay(), arguments[1], arguments[2]);
+		else
+			return '';
+	}else
+		return _dayName(new Date().getDay(), arguments[1], arguments[2]);
+}
+function _dayName(num, dfName, ctx){
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectNodes(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/*[local-name()='days' and namespace-uri()='http://exslt.org/dates-and-times']" +
+			"/*[local-name()='day' and namespace-uri()='http://exslt.org/dates-and-times']/text()");
+		if (nodes != null)
+			return nodes[num].nodeValue;
+		else
+			return '';
+	}else
+		return gaLang[gsLang]["days"][num*1];
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>dayOfWeekInMonth</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function dayOfWeekInMonth(){
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date"))
+			)
+			return _dayOfWeekInMonth(oDate, arguments[1], arguments[2]);
+		else
+			return Number.NaN;
+	}else
+		return _dayOfWeekInMonth(new Date(), arguments[1], arguments[2]);	
+}
+function _dayOfWeekInMonth(oDate, dfName, ctx){
+	var fdow = 0;
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectSingleNode(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/@first-day-of-week");
+		if (nodes != null)
+			fdow = gaDayNames[nodes.nodeValue];
+	}
+	if (fdow > (oDate.getDay()-1))
+		return Math.floor((oDate.getDate())/7)+1;
+	else
+		return Math.floor((oDate.getDate())/7) + 1;
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>difference</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function difference(){
+	if (((d1 = _validDate(arguments[0], "xs:dateTime")) ||
+		 (d1 = _validDate(arguments[0], "xs:date")) ||
+		 (d1 = _validDate(arguments[0], "xs:gYearMonth")) ||
+		 (d1 = _validDate(arguments[0], "xs:gYear"))
+		) &&
+		((d2 = _validDate(arguments[1], "xs:dateTime")) ||
+		 (d2 = _validDate(arguments[1], "xs:date")) ||
+		 (d2 = _validDate(arguments[1], "xs:gYearMonth")) ||
+		 (d2 = _validDate(arguments[1], "xs:gYear"))
+		 )
+		){// truncation
+		var diffMil = d2.valueOf() - d1.valueOf();
+		return _formatDuration(diffMil);
+	}
+	return Number.NaN;
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>duration</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="seconds" type="number" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function duration(){
+	var oDate;
+	if (arguments.length > 0){
+		var nN = new Number(arguments[0]);
+		if (isNaN(nN))
+			return '';
+		else
+			return _formatDuration(arguments[0] * 1000);
+	}else
+		return _formatDuration(seconds() * 1000);
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>formatDate</doc:name>
+	<doc:version>1.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="no"></doc:arg>
+		<doc:arg name="format" type="string" default="''" optional="no"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="no"></doc:arg>
+		<doc:arg name="context" type="document" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function formatDate(date, format, dateF, ctx){
+	var oDate;
+	var re;
+	var retString = "";
+	if ((oDate = _validDate(date, "xs:dateTime")) ||
+		(oDate = _validDate(date, "xs:date")) ||
+		(oDate = _validDate(date, "xs:time")) ||
+		(oDate = _validDate(date, "xs:gYearMonth")) ||
+		(oDate = _validDate(date, "xs:gYear")) ||
+		(oDate = _validDate(date, "xs:gMonthDay")) ||
+		(oDate = _validDate(date, "xs:gMonth")) ||
+		(oDate = _validDate(date, "xs:gDay"))
+		){
+		for (var i=0; i < format.length;){
+			var s = i;
+			switch(format.substr(i, 1)){
+				case "G"://        era designator          (Text)              AD
+					while (format.substr(i, 1)=="G"){i++;}
+					if (oDate.getFullYear() < 0){
+						retString += "BC";
+					}else{
+						retString += "AD";
+					}
+					break;
+				case "y"://        year                    (Number)            1996
+					while (format.substr(i, 1)=="y"){i++;}
+					if (i-s > 2){
+						retString += oDate.getFullYear();
+					}else{
+						retString += oDate.getFullYear().toString().substring(4-(i-s));
+					}
+					break;
+				case "M"://        month in year           (Text &amp; Number)     July &amp; 07
+					while (format.substr(i, 1)=="M"){i++;}
+					if (i-s <= 2){
+						retString += pad(oDate.getMonth()+1);
+					}else{
+						retString += _monthName(oDate.getMonth(), dateF, ctx);
+					}
+					break;
+				case "d"://        day in month            (Number)            10
+					while (format.substr(i, 1)=="d"){i++;}
+					retString += pad(oDate.getDate());
+					break;
+				case "h"://        hour in am/pm (1~12)    (Number)            12
+					while (format.substr(i, 1)=="h"){i++;}
+					if (oDate.getHours() > 12){
+						retString += pad(oDate.getHours()-12);
+					}else{
+						retString += pad(oDate.getHours());
+					}
+					break;
+				case "H"://        hour in day (0~23)      (Number)            0
+					while (format.substr(i, 1)=="H"){i++;}
+					retString += oDate.getHours();
+					break;
+				case "m"://        minute in hour          (Number)            30
+					while (format.substr(i, 1)=="m"){i++;}
+					retString += pad(oDate.getMinutes());
+					break;
+				case "s"://        second in minute        (Number)            55
+					while (format.substr(i, 1)=="s"){i++;}
+					retString += pad(oDate.getSeconds());
+					break;
+				case "S"://        millisecond             (Number)            978
+					while (format.substr(i, 1)=="S"){i++;}
+					retString += oDate.getMilliseconds();
+					break;
+				case "E"://        day in week             (Text)              Tuesday
+					while (format.substr(i, 1)=="E"){i++;}
+					retString += dayInWeek(oDate, dateF, ctx);
+					break;
+				case "D"://        day in year             (Number)            189
+					while (format.substr(i, 1)=="D"){i++;}
+					retString += _dayInYear(oDate.getFullYear(), oDate.getMonths(), oDate.getDate());
+					break;
+				case "F"://        day of week in month    (Number)            2 (2nd Wed in July)
+					while (format.substr(i, 1)=="F"){i++;}
+					retString += dayOfWeekInMonth(oDate, dateF, ctx);
+					break;
+				case "w"://        week in year            (Number)            27
+					while (format.substr(i, 1)=="w"){i++;}
+					retString += weekInYear(oDate, dateF, ctx);
+					break;
+				case "W"://        week in month           (Number)            2
+					while (format.substr(i, 1)=="W"){i++;}
+					retString += weekInMonth(oDate, dateF, ctx);
+					break;
+				case "a"://        am/pm marker            (Text)              PM
+					while (format.substr(i, 1)=="a"){i++;}
+					if (oDate.getHours() > 12 ){
+						retString += "PM"
+					}else{
+						retString += "AM"
+					}
+					break;
+				case "k"://        hour in day (1~24)      (Number)            24
+					while (format.substr(i, 1)=="k"){i++;}
+					retString += oDate.getHours();
+					break;
+				case "K"://        hour in am/pm (0~11)    (Number)            0
+					while (format.substr(i, 1)=="K"){i++;}
+					if (oDate.getHours() > 12){
+						retString += oDate.getHours()-12;
+					}else{
+						retString += oDate.getHours();
+					}
+					break;
+				case "z"://        time zone               (Text)              Pacific Standard Time
+				
+				
+				
+					while (format.substr(i, 1)=="z"){i++;}
+					var tzo = oDate.getTimezoneOffset();
+					retString += (tzo < 0?"-":"+") + pad(Math.abs(tzo / 60)) + ":" + pad(tzo % 60);
+ 					break;
+ 				case "'"://        escape for text         (Delimiter)
+ 					if (format.substr(i+1, 1) == "'"){
+ 						i++;
+ 						while (format.substr(i, 1)=="'"){i++;}
+ 						retString += "'";
+ 					}else{
+ 						i++;
+ 						while (format.substr(i, 1)!="'" && i <= format.length){retString += format.substr(i++, 1);}
+ 						if (i >= format.length)return '';
+ 						i++;
+ 					}
+ 					break;
+				default:
+					retString += format.substr(i, 1);
+					i++;
+					break;
+			}
+		}
+	}
+	return retString;
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>hourInDay</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function hourInDay(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+		    (oDate = _validDate(arguments[0], "xs:time"))
+		   )
+			return oDate.getHours();
+		else
+			return Number.NaN;
+	}else
+		return new Date().getHours();
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>leapYear</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="boolean" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function leapYear(){
+	if (arguments.length > 0 && arguments[0] != ''){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date")) ||
+			(oDate = _validDate(arguments[0], "xs:gYearMonth")) ||
+			(oDate = _validDate(arguments[0], "xs:gYear"))
+		    )
+			return (_isLeap(oDate.getFullYear())?true:false);
+		else
+			return Number.NaN;
+	}else
+		return (_isLeap(new Date().getFullYear())?true:false);
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>minuteInHour</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function minuteInHour(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+		    (oDate = _validDate(arguments[0], "xs:time"))
+		   )
+			return oDate.getMinutes();
+		else
+			return Number.NaN;
+	}else
+		return new Date().getMinutes();
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>monthAbbreviation</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function monthAbbreviation(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date")) ||
+			(oDate = _validDate(arguments[0], "xs:gYearMonth")) ||
+			(oDate = _validDate(arguments[0], "xs:gMonthDay"))
+		    )
+			return _monthAbbreviation(oDate.getMonth(), arguments[1], arguments[2]);
+		else
+			return '';
+	}else
+		return _monthAbbreviation(new Date().getMonth(), arguments[1], arguments[2]);
+}
+function _monthAbbreviation(num, dfName, ctx){//
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectNodes(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/*[local-name()='months' and namespace-uri()='http://exslt.org/dates-and-times']" +
+			"/*[local-name()='month' and namespace-uri()='http://exslt.org/dates-and-times']/@abbr");
+		if (nodes != null)
+			return nodes[num].nodeValue;
+		else
+			return '';
+	}else{ //we could try local
+		return gaLang[gsLang]["shortMonths"][num*1];
+	}
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>monthInYear</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function monthInYear(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date")) ||
+			(oDate = _validDate(arguments[0], "xs:gYearMonth")) ||
+			(oDate = _validDate(arguments[0], "xs:gMonthDay")) ||
+			(oDate = _validDate(arguments[0], "xs:gYear"))
+		    )
+			return oDate.getMonth()+1;
+		else
+			return Number.NaN;
+	}else
+		return new Date().getMonth()+1;
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>monthName</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function monthName(){//
+	if (arguments.length > 0){// && arguments[0] != ''
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date")) ||
+			(oDate = _validDate(arguments[0], "xs:gYearMonth")) ||
+			(oDate = _validDate(arguments[0], "xs:gMonthDay"))
+		    )
+			return _monthName(oDate.getMonth(), arguments[1], arguments[2]);
+		else
+			return '';
+	}else
+		return _monthName(new Date().getMonth(), arguments[1],  arguments[2]);
+}
+function _monthName(num, dfName, ctx){//
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectNodes(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/*[local-name()='months' and namespace-uri()='http://exslt.org/dates-and-times']" +
+			"/*[local-name()='month' and namespace-uri()='http://exslt.org/dates-and-times']/text()");
+		if (nodes != null)
+			return nodes[num].nodeValue;
+		else
+			return '';
+	}else
+		return gaLang[gsLang]["months"][num*1];
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>parseDate</doc:name>
+	<doc:version>1.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="input-format" type="string" default="''" optional="no"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="document" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function parseDate(date, inFormat, dfName, ctx){//0001
+	var oDate;
+	if (inFormat == ""){
+		if ((oDate = _validDate(date, "xs:dateTime")) ||
+			(oDate = _validDate(date, "xs:date")) ||
+			(oDate = _validDate(date, "xs:time")) ||
+			(oDate = _validDate(date, "xs:gYearMonth")) ||
+			(oDate = _validDate(date, "xs:gYear")) ||
+			(oDate = _validDate(date, "xs:gMonthDay")) ||
+			(oDate = _validDate(date, "xs:gMonth")) ||
+			(oDate = _validDate(date, "xs:gDay"))
+			){
+			return _formatDate(oDate, "xs:dateTime");
+		}
+	}else{
+		if (oDate = _validDate(date, inFormat))
+      return _formatDate(oDate, dfName);
+		else
+			return '';
+	}
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>secondInMinute</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function secondInMinute(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+		    (oDate = _validDate(arguments[0], "xs:time"))
+		   )
+			return oDate.getSeconds();
+		else
+			return Number.NaN;
+	}else
+		return new Date().getSeconds();
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>seconds</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function seconds(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date")) ||
+			(oDate = _validDate(arguments[0], "xs:gYearMonth")) ||
+			(oDate = _validDate(arguments[0], "xs:gYear"))
+			)
+			return oDate.valueOf()/1000;
+		else 
+			if (oDate = _validDuration(arguments[0]))
+				return oDate.Seconds();
+			else
+				return Number.NaN;
+	}else
+		return Math.floor(new Date().valueOf()/1000);//current local date/time
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>sum</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="durations" type="node-set" default="''" optional="no"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function sum(ctx){
+	var sDate = "P0S";
+	if (typeof(ctx) == "object"){
+		if (ctx.length){
+			for (var i=0; i < ctx.length; i++){
+				ctxN  = ctx.item(i);
+				if (ctxN.nodeType == 1){
+					if (!(sDate = addDuration(sDate, _wander(ctxN))))
+						return '';
+				}
+				if (ctxN.nodeType == 2){
+					if (!(sDate = addDuration(sDate, ctxN.nodeValue)))
+						return '';
+				}
+			}
+		}else{
+			if (!(sDate = addDuration(sDate, ctx.nodeValue)))
+					return '';
+		}
+	}else{
+		return '';
+	}
+	return sDate;
+}
+function   _wander(ctx){
+	var sDate = "P0S";
+	for (var i=0; i < ctx.childNodes.length; i++){
+		ctxN = ctx.childNodes[i];
+		switch(ctxN.nodeType){
+			case 1:
+				if (!(sDate = addDuration(sDate, _wander(ctxN))))
+						return '';
+				break;
+			case 3:
+				if (!(sDate = addDuration(sDate, ctxN.nodeValue)))
+						return '';
+				break;
+			default:
+				break;
+		}
+	}
+	return sDate;
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>time</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function time(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime"))||
+			(oDate = _validDate(arguments[0], "xs:time"))
+		)
+			return _formatDate(oDate, "xs:time");
+		else
+			return '';
+	}else
+		return _formatDate(new Date(), "xs:time");
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>weekInMonth</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function weekInMonth(){
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date"))
+			)
+			return _weekInMonth(oDate, arguments[1], arguments[2]);
+		else
+			return Number.NaN;
+	}else
+		return _weekInMonth(new Date(), arguments[1], arguments[2]);	
+}
+function _weekInMonth(oDate, dfName, ctx){
+	var fdow = 0;
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectSingleNode(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/@first-day-of-week");
+		if (nodes != null)
+			fdow = gaDayNames[nodes.nodeValue];
+	}
+	var f = new Date(oDate);
+	f.setDate(1)
+	var fd = f.getDay()-1;
+	var dt = oDate.getDate() + fd - fdow;
+	return Math.floor((dt)/7)+1;
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>weekInYear</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function weekInYear(){
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date"))
+			)
+			return _weekInYear(oDate, arguments[1], arguments[2]);
+	}else 
+		return _weekInYear(new Date());
+	return '';
+}
+function _weekInYear(oDate, dfName, ctx){
+	var fdow = 0;
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectSingleNode(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/@first-day-of-week");
+		if (nodes != null)
+			fdow = gaDayNames[nodes.nodeValue];
+		return Math.ceil(_dayInYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate()+(7-fdow)) / 7);
+	}else
+		return Math.ceil(_dayInYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate()) / 7);
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>year</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function year(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date")) ||
+			(oDate = _validDate(arguments[0], "xs:gYearMonth")) ||
+			(oDate = _validDate(arguments[0], "xs:gYear"))
+		    )
+			return oDate.getFullYear();
+		else
+			return Number.NaN;
+	}else
+		return new Date().getFullYear();
+}
+/**
+Private functions.
+**/
+function _validDate(date, format){
+	var parts;
+	var oDate = new Date(-62135596800000); // Mon Jan 1 00:00:00 UTC 1
+	switch(format){
+		case "xs:dateTime": //(CCYY-MM-DDThh:mm:ss)
+			var re = new RegExp("^([0-9]{4})-([0-9]{2})-([0-9]{2})(T([0-9]{2})(:([0-9]{2})(:([0-9]{2}))?)?)?(Z)?([\+\-][0-9]{2}:[0-9]{2})?$");
+			if (parts=re.exec(date)){
+				if (parts[10] == "Z"){
+					oDate.setFullYear(parts[1], parts[2]-1, parts[3]);
+					oDate.setHours(parts[5], parts[7], parts[9]);
+					oDate.setMinutes(oDate.getMinutes()-oDate.getTimezoneOffset());
+					gsSuppliedFormat = "xs:dateTime";
+					return oDate;
+				}else{
+					oDate.setFullYear(parts[1], parts[2]-1, parts[3]);
+					oDate.setHours(parts[5], parts[7], parts[9]);
+					gsSuppliedFormat = "xs:dateTime";
+					return oDate;
+				}
+			}
+			break;
+		case "xs:date": //(CCYY-MM-DD) 
+			var re = new RegExp("^([0-9]{4})-([0-9]{2})-([0-9]{2})$");
+			if (parts=re.exec(date)){
+				oDate.setFullYear(parts[1], parts[2]-1, parts[3]);
+				gsSuppliedFormat = "xs:date";
+				return oDate;
+			}
+			break;
+		case "xs:time": //(hh:mm:ss)
+			var re = new RegExp("^([0-9]{2})(:([0-9]{2})(:([0-9]{2}))?)?(Z)?$");
+			if (parts=re.exec(date)){
+				if (parts[9] == "Z"){
+					oDate.setHours(parts[1], parts[3], parts[5]);
+					oDate.setMinutes(oDate.getMinutes()-oDate.getTimezoneOffset());
+					gsSuppliedFormat = "xs:time";
+					return oDate;
+				}else{
+					oDate.setHours(parts[1], parts[3], parts[5]);
+					gsSuppliedFormat = "xs:time";
+					return oDate;
+				}
+			}
+			break;
+		case "xs:gYearMonth": //(CCYY-MM)
+			var re = new RegExp("^([0-9]{4})-([0-9]{2})$");
+			if (parts=re.exec(date)){
+				oDate.setFullYear(parts[1], parts[2]-1);
+				gsSuppliedFormat = "xs:gYearMonth";
+				return oDate;
+			}
+			break;
+		case "xs:gYear": //(CCYY)
+			var re = new RegExp("^([0-9]{4})$");
+			if (parts=re.exec(date)){
+				oDate.setFullYear(parts[1]);
+				gsSuppliedFormat = "xs:gYear";
+				return oDate;
+			}
+			break;
+		case "xs:gMonthDay": //(^--MM-DD)
+			var re = new RegExp("--([0-9]{2})-([0-9]{2})");
+			if (parts=re.exec(date)){
+				oDate.setMonth(parts[1]-1, parts[2]);
+				gsSuppliedFormat = "xs:gMonthDay";
+				return oDate;
+			}
+			break;
+		case "xs:gMonth": //(--MM--)
+			var re = new RegExp("^--([0-9]{2})--$");
+			if (parts=re.exec(date)){
+				oDate.setMonth(parts[1]-1);
+				gsSuppliedFormat = "xs:gMonth";
+				return oDate;
+			}
+			break;
+		case "xs:gDay": //(---DD)
+			var re = new RegExp("^---([0-9]{2})$");
+			if (parts=re.exec(date)){
+				oDate.setDate(parts[1]);
+				gsSuppliedFormat = "xs:gDay";
+				return oDate;
+			}
+			break;
+		default:
+			// format string 
+			var Z = "";
+			for (var i=0,j=0; i < format.length & oDate.toString() != "NaN";){
+				var s = j;
+				switch(format.substr(i, 1)){
+					case "G"://        era designator          (Text)              AD
+						while (format.substr(i, 1)=="G"){i++;j++;}
+						j++;
+						if (date.substr(s,j-s) == "BC" || date.substr(s,j-s) == "bc"){
+							oDate.setFullYear(-oDate.getFullYear);
+						}
+						break;
+					case "y"://        year                    (Number)            1996
+						while (format.substr(i, 1)=="y"){i++;j++;}
+						oDate.setYear(date.substr(s,j-s));
+						break;
+					case "M"://        month in year           (Text &amp; Number)     July &amp; 07
+						while (format.substr(i, 1)=="M"){i++;j++;}
+						if (i-s <= 2){
+							oDate.setMonth(date.substr(s,j-s)-1);
+						}else{
+							oDate.setMonth(_monthNumber(date.substr(s,j-s)));
+						}
+						break;
+					case "d"://        day in month            (Number)            10
+						while (format.substr(i, 1)=="d"){i++;j++;}
+						oDate.setDate(date.substr(s,j-s));
+						break;
+					case "h"://        hour in am/pm (1~12)    (Number)            12
+						while (format.substr(i, 1)=="h"){i++;j++;}
+						oDate.setHours(date.substr(s,j-s));
+						break;
+					case "H"://        hour in day (0~23)      (Number)            0
+						while (format.substr(i, 1)=="H"){i++;j++;}
+						oDate.setHours(date.substr(s,j-s));
+						break;
+					case "m"://        minute in hour          (Number)            30
+						while (format.substr(i, 1)=="m"){i++;j++;}
+						oDate.setMinutes(date.substr(s,j-s));
+						break;
+					case "s"://        second in minute        (Number)            55
+						while (format.substr(i, 1)=="s"){i++;j++;}
+						oDate.setSeconds(date.substr(s,j-s));
+						break;
+					case "S"://        millisecond             (Number)            978
+						while (format.substr(i, 1)=="S"){i++;j++;}
+						oDate.setMilliseconds(date.substr(s,j-s));
+						break;
+					case "E"://        day in week             (Text)              Tuesday
+						while (format.substr(i, 1)=="E"){i++;j++;}
+						while (format.substr(i+1, 1)!=date.substr(j, 1)){j++;}
+						break;
+					case "D"://        day in year             (Number)            189
+						while (format.substr(i, 1)=="D"){i++;j++;}
+						while (format.substr(i+1, 1)!=date.substr(j, 1)){j++;}
+						break;
+					case "F"://        day of week in month    (Number)            2 (2nd Wed in July)
+						while (format.substr(i, 1)=="F"){i++;j++;}
+						break;
+					case "w"://        week in year            (Number)            27
+						while (format.substr(i, 1)=="w"){i++;j++;}
+						while (format.substr(i+1, 1)!=date.substr(j, 1)){j++;}
+						break;
+					case "W"://        week in month           (Number)            2
+						while (format.substr(i, 1)=="W"){i++;j++;}
+						while (format.substr(i+1, 1)!=date.substr(j, 1)){j++;}
+						break;
+					case "a"://        am/pm marker            (Text)              PM
+						while (format.substr(i, 1)=="a"){i++;j++;}
+						j++;
+						if (date.substr(s,j-s) == "PM" || date.substr(s,j-s) == "pm")
+							oDate.setHours(oDate.getHours()+12);
+						break;
+					case "k"://        hour in day (1~24)      (Number)            24
+						while (format.substr(i, 1)=="k"){i++;j++;}
+						oDate.setHours(date.substr(s,j-s));
+						break;
+					case "K"://        hour in am/pm (0~11)    (Number)            0
+						while (format.substr(i, 1)=="K"){i++;j++;}
+						oDate.setHours(date.substr(s,j-s));
+						break;
+					case "z"://        time zone               (Text)              Pacific Standard Time
+						while (format.substr(i, 1)=="z"){i++;j++;}
+						while (format.substr(i+1, 1)!=date.substr(j, 1)){j++;}
+						//oDate.setMinutes(oDate.getMinutes() - oDate.getTimezoneOffset());
+						Z = date.substr(s,j-s);
+ 						break;
+ 					case "'"://        escape for text         (Delimiter)
+ 						if (format.substr(i+1, 1) == "'"){
+ 							i+=2;
+ 						}else{
+ 							i++;
+ 							while (format.substr(i, 1)!="'"){i++;j++;}
+ 							i++;
+ 						}
+ 						break;
+					default:
+						if (format.substr(i, 1) != date.substr(j, 1)){
+							return false;
+						}
+						i++;j++;
+						break;
+				}
+			}
+			if (j < date.length)
+				return false;
+			if (oDate.toString() != "NaN"){
+				if (Z != ""){
+					var re = new RegExp("([\+\-][0-9]{2})?:([0-9]{2})?");
+					if (parts=re.exec(Z)){
+						// check GMT/BST
+						var tzo = parts[1]*60 + parts[2];
+						//if (tzo != new Date().getTimezoneOffset()){
+						//	oDate.setMinutes(oDate.getMinutes() - (oDate.getTimezoneOffset() - tzo))
+						//}
+					}
+				}
+				gsSuppliedFormat = "custom";
+				return oDate;
+			}
+			break;
+	}
+	return false;
+}
+function _formatDate(oDate, format){
+	if (oDate == Number.NaN)return Number.NaN;
+	switch(format){
+		case "xs:dateTime": //(CCYY-MM-DDThh:mm:ss)
+			var tzo = oDate.getTimezoneOffset(); 
+			return oDate.getFullYear() + "-" + pad(oDate.getMonth()+1) + "-" + pad(oDate.getDate()) + "T" +
+				   pad(oDate.getHours()) + ":" + pad(oDate.getMinutes()) + ":" + pad(oDate.getSeconds()) + (tzo < 0?"-":"+") + pad(Math.abs(tzo/60)) + ":" + pad(tzo % 60);
+			break;
+		case "xs:date": //(CCYY-MM-DD) 
+			return oDate.getFullYear() + "-" + pad(oDate.getMonth()+1) + "-" + pad(oDate.getDate());
+			break;
+		case "xs:time": //(hh:mm:ss)
+			var tzo = oDate.getTimezoneOffset(); 
+			return pad(oDate.getHours()) + ":" + pad(oDate.getMinutes()) + ":" + pad(oDate.getSeconds()) + (tzo < 0?"-":"+") + pad(Math.abs(tzo/60)) + ":" + pad(tzo % 60);
+			break;
+		case "xs:gYearMonth": //(CCYY-MM)
+			return oDate.getFullYear() + "-" + pad(oDate.getMonth()+1);
+			break;
+		case "xs:gYear": //(CCYY)
+			return oDate.getFullYear();
+			break;
+		case "xs:gMonthDay": //(--MM-DD)
+			return pad(oDate.getMonth() + 1) + "-" + pad(oDate.getDate());
+			break;
+		case "xs:gMonth": //(--MM--)
+			return pad(oDate.getMonth()+1);
+			break;
+		case "xs:gDay": //(---DD)
+			return pad(oDate.getDate());
+			break;
+	}
+	return false;
+}
+function pad(v){
+	return (v<10?"0"+v:v);
+}
+
+function _validDuration(d){
+        var parts;
+        var re = new RegExp("^([\-])?P(([0-9]+)Y)?(([0-9]+)M)?(([0-9]+)D)?((T)?(([0-9]+)H)?(([0-9]+)M)?((([0-9]+)(\.([0-9]+))?)S)?)?$");
+        if (parts = re.exec(d)){
+                if ((/T$/.exec(d)) || (parts[9] == "T" && parts[11]+parts[13]+parts[16]+parts[18]== ""))// ~(:+(|) duh!!!
+                        return Number.NaN;
+                return new Duration(parts[1], parts[3], parts[5], parts[7], parts[11], parts[13], parts[16], parts[18]);
+        }
+        return Number.NaN;
+}
+
+function Duration(pm, years, months, days, hours, minutes, seconds, fraction){
+	this.pm = pm;
+	this.years = years*1;
+	this.months = months*1;
+	this.days = days*1;
+	this.hours = hours*1;
+	this.minutes = minutes*1;
+	this.seconds = seconds*1;
+	this.fraction = fraction*1;
+	this.milliseconds = eval('0.'+fraction) * 100;
+	this.mask = ((this.years?1:0)<<6) + ((this.months?1:0)<<5) + ((this.days?1:0)<<4) + ((this.hours?1:0)<<3) + ((this.minutes?1:0)<<2) + ((this.seconds?1:0)<<1) + (this.milliseconds?1:0);
+	this.addDate = function(d){d.setFullYear(eval(this.pm+this.years)+d.getFullYear(),eval(this.pm+this.months)+d.getMonth(),eval(this.pm+this.days)+d.getDate());d.setHours(eval(this.pm+this.hours)+d.getHours(),eval(this.pm+this.minutes)+d.getMinutes(),eval(this.pm+this.seconds)+d.getSeconds());d.setMilliseconds(eval(this.pm+this.milliseconds));return d;}
+	this.Seconds = function(){if (this.years || this.months)return Number.NaN;return this.days*giDayMill + this.hours*giHourMill + this.minutes*giMinMill + this.seconds*giSecMill;}
+}
+var giYearMill = 31536000000;
+var giMonthMill = 2592000000;
+var giDayMill = 86400000;
+var giHourMill = 3600000;
+var giMinMill = 60000;
+var giSecMill = 1000;
+function _formatDuration(du){
+	if (typeof(du) == "object"){
+		var pm = du.pm;
+		var y = du.years;
+		var m = du.months;
+		var d = du.days;
+		var h = du.hours;
+		var n = du.minutes;
+		var s = du.seconds + du.milliseconds/1000;
+		
+		if (y+m+d+h+n+s == 0)
+			return 'P0S';
+		return pm + "P" + 
+				(y!=0?y + "Y":'') + 
+				(m!=0?m + "M":'') + 
+				(d!=0?d + "D":'') + 
+				(h+n+s!=0?"T":'') +
+				(h!=0?h + "H":'') + 
+				(n!=0?n + "M":'') + 
+				(s!=0?s + "S":'');
+	}else{
+		var pm = (du<0?'-':'');
+		du = Math.abs(du);
+		var d = Math.floor((du) / giDayMill);
+		var h = Math.floor((du % giDayMill) / giHourMill);
+		var n = Math.floor((du % giHourMill) / giMinMill);
+		var s = Math.floor((du % giMinMill) / giSecMill) + (du % giSecMill)/1000;
+		return pm + "P" + 
+				(d!=0?d + "D":'') + 
+				(h+n+s!=0?"T":'') +
+				(h!=0?h + "H":'') + 
+				(n!=0?n + "M":'') + 
+				(s!=0?s + "S":'');
+	}
+}
+]]>
+</msxsl:script>
+
+</xsl:stylesheet>
Index: /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.js
===================================================================
--- /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.js (revision 296)
+++ /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.js (revision 296)
@@ -0,0 +1,1257 @@
+/**
+<doc:module date="2001-06-12">
+   <doc:module>exslt:date-time</doc:module>
+   <doc:name>dates</doc:name>
+   <doc:version>2.0</doc:version>
+   <doc:language>exslt:javascript</doc:language>
+   <doc:meta>
+      <doc:author email="chris@bayes.co.uk" url="http://www.bayes.co.uk">Chris Bayes</doc:author>
+      <doc:summary>Implementation of EXSLT - Dates (http://www.exslt.org/date)</doc:summary>
+      <doc:todo>_validDuration is not 100%</doc:todo>
+      <doc:todo>All timezone code.</doc:todo>
+   </doc:meta>
+</doc:module>
+**/
+var gsSuppliedFormat = "";
+var gsLang = "en";
+var gaLang = new Array();
+// en 
+gaLang["en"] = new Array();
+gaLang["en"]["months"] = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
+gaLang["en"]["shortMonths"] = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
+gaLang["en"]["days"] = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
+gaLang["en"]["shortDays"] = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
+
+
+var gaDayNames = new Array();
+gaDayNames["sunday"] = 0;gaDayNames["monday"] = 1;gaDayNames["tuesday"] = 2;gaDayNames["wednesday"] = 3;gaDayNames["thursday"] = 4;gaDayNames["friday"] = 5;gaDayNames["saturday"] = 6;
+var gaMonthCnt = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
+var gaMonthCntL = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
+function _isLeap(y){return ( ((y%4==0)&(y%100!=0))|(y%400==0) );}
+function _dayOfWeek(y,d){return ( ((y-1)+Math.floor((y-1)/4)-Math.floor((y-1)/100)+Math.floor((y-1)/400)+d)%7);}
+function _dayInYear(y,m,d){return (m==0?d:eval( (_isLeap(y)?gaMonthCntL.slice(0,m).join("+"):gaMonthCnt.slice(0,m).join("+")) )+(d*1) );}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>add</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="no"></doc:arg>
+		<doc:arg name="duration" type="string" default="''" optional="no"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function add(){//
+	var d1,d2;
+	if (((d1 = _validDate(arguments[0], "xs:dateTime")) ||
+		 (d1 = _validDate(arguments[0], "xs:date")) ||
+		 (d1 = _validDate(arguments[0], "xs:gYearMonth")) ||
+		 (d1 = _validDate(arguments[0], "xs:gYear"))
+		) && 
+		(d2 = _validDuration(arguments[1])))
+		return _formatDate(d2.addDate(d1), gsSuppliedFormat);
+	return '';
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>addDuration</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="duration" type="string" default="''" optional="no"></doc:arg>
+		<doc:arg name="duration" type="string" default="''" optional="no"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function addDuration(duration1, duration2){
+	if ((d1 = _validDuration(duration1)) && (d2 = _validDuration(duration2))){
+		var d1mnth = d1.years *12 + d1.months;
+		var d1secs = d1.days*86400 + d1.hours*3600 + d1.minutes*60 + (d1.seconds+'.'+d1.fraction)*1;
+		var d2mnth = d2.years *12 + d2.months;
+		var d2secs = d2.days*86400 + d2.hours*3600 + d2.minutes*60 + (d2.seconds+'.'+d2.fraction)*1;
+		var mnthdiff = (d1.pm+d1mnth)*1 + (d2.pm+d2mnth)*1;
+		var secsdiff = (d1.pm+d1secs)*1 + (d2.pm+d2secs)*1;
+		if ((mnthdiff < 0 && secsdiff > 0) || (mnthdiff > 0 && secsdiff < 0))
+			return '';
+		var secs = secsdiff % 60;
+		var pm = (mnthdiff<0||secsdiff<0?'-':'');
+		mnthdiff = Math.abs(mnthdiff);
+		secsdiff = Math.abs(secsdiff);
+		return _formatDuration(new Duration(pm, 0, mnthdiff, Math.floor(secsdiff/86400), Math.floor((secsdiff%86400)/3600), Math.floor((secsdiff%3600)/60), Math.floor(secs), Math.floor(secs%1)));
+	}
+	return '';
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>date</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function date(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date"))
+			)
+			return _formatDate(oDate, "xs:date");
+		else
+			return '';
+	}else
+		return _formatDate(new Date(), "xs:date");
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>dateTime</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args />
+</doc:function>
+**/
+function dateTime(){//must be UTC/Z
+	if (arguments.length > 0)
+		dateTime_invalidArgument.error;
+	var oDate = new Date();
+	return _formatDate(oDate, "xs:dateTime");
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>dayAbbreviation</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function dayAbbreviation(){
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+		    (oDate = _validDate(arguments[0], "xs:date"))
+		   )
+			return _dayAbbreviation(oDate.getDay(), arguments[1], arguments[2]);
+		else
+			return '';
+	}else
+		return _dayAbbreviation(new Date().getDay(), arguments[1], arguments[2]);
+}
+function _dayAbbreviation(num, dfName, ctx){
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectNodes(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/*[local-name()='days' and namespace-uri()='http://exslt.org/dates-and-times']" +
+			"/*[local-name()='day' and namespace-uri()='http://exslt.org/dates-and-times']/@abbr");
+		if (nodes != null)
+			return nodes[num].nodeValue;
+		else
+			return '';
+	}else{ //we could try local
+		return gaLang[gsLang]["shortDays"][num*1];
+	}
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>dayInMonth</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function dayInMonth(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date")) ||
+			(oDate = _validDate(arguments[0], "xs:gMonthDay")) ||
+			(oDate = _validDate(arguments[0], "xs:gDay"))
+		    )
+			return oDate.getDate();
+		else
+			return Number.NaN
+	}else
+		return new Date().getDate();
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>dayInWeek</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function dayInWeek(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+		    (oDate = _validDate(arguments[0], "xs:date"))
+		   )
+			return _dayInWeek(oDate, arguments[1], arguments[2]);
+		else
+			return Number.NaN;
+	}else
+		return _dayInWeek(new Date(), arguments[1], arguments[2]);
+}
+function _dayInWeek(oDate, dfName, ctx){
+	var fdow = 0;
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectSingleNode(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/@first-day-of-week");
+		if (nodes != null)
+			fdow = gaDayNames[nodes.nodeValue];
+	}
+	return (oDate.getDay()-fdow<0?oDate.getDay()-fdow+7:oDate.getDay()-fdow)+1;
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>dayInYear</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function dayInYear(){
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date"))
+			)
+			return _dayInYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate());
+		else
+			return Number.NaN;
+	}else{
+		var oDate = new Date()
+		return _dayInYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate());
+	}
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>dayName</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function dayName(){
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+		    (oDate = _validDate(arguments[0], "xs:date"))
+		   )
+			return _dayName(oDate.getDay(), arguments[1], arguments[2]);
+		else
+			return '';
+	}else
+		return _dayName(new Date().getDay(), arguments[1], arguments[2]);
+}
+function _dayName(num, dfName, ctx){
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectNodes(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/*[local-name()='days' and namespace-uri()='http://exslt.org/dates-and-times']" +
+			"/*[local-name()='day' and namespace-uri()='http://exslt.org/dates-and-times']/text()");
+		if (nodes != null)
+			return nodes[num].nodeValue;
+		else
+			return '';
+	}else
+		return gaLang[gsLang]["days"][num*1];
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>dayOfWeekInMonth</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function dayOfWeekInMonth(){
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date"))
+			)
+			return _dayOfWeekInMonth(oDate, arguments[1], arguments[2]);
+		else
+			return Number.NaN;
+	}else
+		return _dayOfWeekInMonth(new Date(), arguments[1], arguments[2]);	
+}
+function _dayOfWeekInMonth(oDate, dfName, ctx){
+	var fdow = 0;
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectSingleNode(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/@first-day-of-week");
+		if (nodes != null)
+			fdow = gaDayNames[nodes.nodeValue];
+	}
+	if (fdow > (oDate.getDay()-1))
+		return Math.floor((oDate.getDate())/7)+1;
+	else
+		return Math.floor((oDate.getDate())/7) + 1;
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>difference</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function difference(){
+	if (((d1 = _validDate(arguments[0], "xs:dateTime")) ||
+		 (d1 = _validDate(arguments[0], "xs:date")) ||
+		 (d1 = _validDate(arguments[0], "xs:gYearMonth")) ||
+		 (d1 = _validDate(arguments[0], "xs:gYear"))
+		) &&
+		((d2 = _validDate(arguments[1], "xs:dateTime")) ||
+		 (d2 = _validDate(arguments[1], "xs:date")) ||
+		 (d2 = _validDate(arguments[1], "xs:gYearMonth")) ||
+		 (d2 = _validDate(arguments[1], "xs:gYear"))
+		 )
+		){// truncation
+		var diffMil = d2.valueOf() - d1.valueOf();
+		return _formatDuration(diffMil);
+	}
+	return Number.NaN;
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>duration</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="seconds" type="number" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function duration(){
+	var oDate;
+	if (arguments.length > 0){
+		var nN = new Number(arguments[0]);
+		if (isNaN(nN))
+			return '';
+		else
+			return _formatDuration(arguments[0] * 1000);
+	}else
+		return _formatDuration(seconds() * 1000);
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>formatDate</doc:name>
+	<doc:version>1.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="no"></doc:arg>
+		<doc:arg name="format" type="string" default="''" optional="no"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="no"></doc:arg>
+		<doc:arg name="context" type="document" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function formatDate(date, format, dateF, ctx){
+	var oDate;
+	var re;
+	var retString = "";
+	if ((oDate = _validDate(date, "xs:dateTime")) ||
+		(oDate = _validDate(date, "xs:date")) ||
+		(oDate = _validDate(date, "xs:time")) ||
+		(oDate = _validDate(date, "xs:gYearMonth")) ||
+		(oDate = _validDate(date, "xs:gYear")) ||
+		(oDate = _validDate(date, "xs:gMonthDay")) ||
+		(oDate = _validDate(date, "xs:gMonth")) ||
+		(oDate = _validDate(date, "xs:gDay"))
+		){
+		for (var i=0; i < format.length;){
+			var s = i;
+			switch(format.substr(i, 1)){
+				case "G"://        era designator          (Text)              AD
+					while (format.substr(i, 1)=="G"){i++;}
+					if (oDate.getFullYear() < 0){
+						retString += "BC";
+					}else{
+						retString += "AD";
+					}
+					break;
+				case "y"://        year                    (Number)            1996
+					while (format.substr(i, 1)=="y"){i++;}
+					if (i-s > 2){
+						retString += oDate.getFullYear();
+					}else{
+						retString += oDate.getFullYear().toString().substring(4-(i-s));
+					}
+					break;
+				case "M"://        month in year           (Text &amp; Number)     July &amp; 07
+					while (format.substr(i, 1)=="M"){i++;}
+					if (i-s <= 2){
+						retString += pad(oDate.getMonth()+1);
+					}else{
+						retString += _monthName(oDate.getMonth(), dateF, ctx);
+					}
+					break;
+				case "d"://        day in month            (Number)            10
+					while (format.substr(i, 1)=="d"){i++;}
+					retString += pad(oDate.getDate());
+					break;
+				case "h"://        hour in am/pm (1~12)    (Number)            12
+					while (format.substr(i, 1)=="h"){i++;}
+					if (oDate.getHours() > 12){
+						retString += pad(oDate.getHours()-12);
+					}else{
+						retString += pad(oDate.getHours());
+					}
+					break;
+				case "H"://        hour in day (0~23)      (Number)            0
+					while (format.substr(i, 1)=="H"){i++;}
+					retString += oDate.getHours();
+					break;
+				case "m"://        minute in hour          (Number)            30
+					while (format.substr(i, 1)=="m"){i++;}
+					retString += pad(oDate.getMinutes());
+					break;
+				case "s"://        second in minute        (Number)            55
+					while (format.substr(i, 1)=="s"){i++;}
+					retString += pad(oDate.getSeconds());
+					break;
+				case "S"://        millisecond             (Number)            978
+					while (format.substr(i, 1)=="S"){i++;}
+					retString += oDate.getMilliseconds();
+					break;
+				case "E"://        day in week             (Text)              Tuesday
+					while (format.substr(i, 1)=="E"){i++;}
+					retString += dayInWeek(oDate, dateF, ctx);
+					break;
+				case "D"://        day in year             (Number)            189
+					while (format.substr(i, 1)=="D"){i++;}
+					retString += _dayInYear(oDate.getFullYear(), oDate.getMonths(), oDate.getDate());
+					break;
+				case "F"://        day of week in month    (Number)            2 (2nd Wed in July)
+					while (format.substr(i, 1)=="F"){i++;}
+					retString += dayOfWeekInMonth(oDate, dateF, ctx);
+					break;
+				case "w"://        week in year            (Number)            27
+					while (format.substr(i, 1)=="w"){i++;}
+					retString += weekInYear(oDate, dateF, ctx);
+					break;
+				case "W"://        week in month           (Number)            2
+					while (format.substr(i, 1)=="W"){i++;}
+					retString += weekInMonth(oDate, dateF, ctx);
+					break;
+				case "a"://        am/pm marker            (Text)              PM
+					while (format.substr(i, 1)=="a"){i++;}
+					if (oDate.getHours() > 12 ){
+						retString += "PM"
+					}else{
+						retString += "AM"
+					}
+					break;
+				case "k"://        hour in day (1~24)      (Number)            24
+					while (format.substr(i, 1)=="k"){i++;}
+					retString += oDate.getHours();
+					break;
+				case "K"://        hour in am/pm (0~11)    (Number)            0
+					while (format.substr(i, 1)=="K"){i++;}
+					if (oDate.getHours() > 12){
+						retString += oDate.getHours()-12;
+					}else{
+						retString += oDate.getHours();
+					}
+					break;
+				case "z"://        time zone               (Text)              Pacific Standard Time
+				
+				
+				
+					while (format.substr(i, 1)=="z"){i++;}
+					var tzo = oDate.getTimezoneOffset();
+					retString += (tzo < 0?"-":"+") + pad(Math.abs(tzo / 60)) + ":" + pad(tzo % 60);
+ 					break;
+ 				case "'"://        escape for text         (Delimiter)
+ 					if (format.substr(i+1, 1) == "'"){
+ 						i++;
+ 						while (format.substr(i, 1)=="'"){i++;}
+ 						retString += "'";
+ 					}else{
+ 						i++;
+ 						while (format.substr(i, 1)!="'" && i <= format.length){retString += format.substr(i++, 1);}
+ 						if (i >= format.length)return '';
+ 						i++;
+ 					}
+ 					break;
+				default:
+					retString += format.substr(i, 1);
+					i++;
+					break;
+			}
+		}
+	}
+	return retString;
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>hourInDay</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function hourInDay(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+		    (oDate = _validDate(arguments[0], "xs:time"))
+		   )
+			return oDate.getHours();
+		else
+			return Number.NaN;
+	}else
+		return new Date().getHours();
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>leapYear</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="boolean" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function leapYear(){
+	if (arguments.length > 0 && arguments[0] != ''){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date")) ||
+			(oDate = _validDate(arguments[0], "xs:gYearMonth")) ||
+			(oDate = _validDate(arguments[0], "xs:gYear"))
+		    )
+			return (_isLeap(oDate.getFullYear())?true:false);
+		else
+			return Number.NaN;
+	}else
+		return (_isLeap(new Date().getFullYear())?true:false);
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>minuteInHour</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function minuteInHour(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+		    (oDate = _validDate(arguments[0], "xs:time"))
+		   )
+			return oDate.getMinutes();
+		else
+			return Number.NaN;
+	}else
+		return new Date().getMinutes();
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>monthAbbreviation</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function monthAbbreviation(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date")) ||
+			(oDate = _validDate(arguments[0], "xs:gYearMonth")) ||
+			(oDate = _validDate(arguments[0], "xs:gMonthDay"))
+		    )
+			return _monthAbbreviation(oDate.getMonth(), arguments[1], arguments[2]);
+		else
+			return '';
+	}else
+		return _monthAbbreviation(new Date().getMonth(), arguments[1], arguments[2]);
+}
+function _monthAbbreviation(num, dfName, ctx){//
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectNodes(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/*[local-name()='months' and namespace-uri()='http://exslt.org/dates-and-times']" +
+			"/*[local-name()='month' and namespace-uri()='http://exslt.org/dates-and-times']/@abbr");
+		if (nodes != null)
+			return nodes[num].nodeValue;
+		else
+			return '';
+	}else{ //we could try local
+		return gaLang[gsLang]["shortMonths"][num*1];
+	}
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>monthInYear</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function monthInYear(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date")) ||
+			(oDate = _validDate(arguments[0], "xs:gYearMonth")) ||
+			(oDate = _validDate(arguments[0], "xs:gMonthDay")) ||
+			(oDate = _validDate(arguments[0], "xs:gYear"))
+		    )
+			return oDate.getMonth()+1;
+		else
+			return Number.NaN;
+	}else
+		return new Date().getMonth()+1;
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>monthName</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function monthName(){//
+	if (arguments.length > 0){// && arguments[0] != ''
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date")) ||
+			(oDate = _validDate(arguments[0], "xs:gYearMonth")) ||
+			(oDate = _validDate(arguments[0], "xs:gMonthDay"))
+		    )
+			return _monthName(oDate.getMonth(), arguments[1], arguments[2]);
+		else
+			return '';
+	}else
+		return _monthName(new Date().getMonth(), arguments[1],  arguments[2]);
+}
+function _monthName(num, dfName, ctx){//
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectNodes(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/*[local-name()='months' and namespace-uri()='http://exslt.org/dates-and-times']" +
+			"/*[local-name()='month' and namespace-uri()='http://exslt.org/dates-and-times']/text()");
+		if (nodes != null)
+			return nodes[num].nodeValue;
+		else
+			return '';
+	}else
+		return gaLang[gsLang]["months"][num*1];
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>parseDate</doc:name>
+	<doc:version>1.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="input-format" type="string" default="''" optional="no"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="document" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function parseDate(date, inFormat, dfName, ctx){//0001
+	var oDate;
+	if (inFormat == ""){
+		if ((oDate = _validDate(date, "xs:dateTime")) ||
+			(oDate = _validDate(date, "xs:date")) ||
+			(oDate = _validDate(date, "xs:time")) ||
+			(oDate = _validDate(date, "xs:gYearMonth")) ||
+			(oDate = _validDate(date, "xs:gYear")) ||
+			(oDate = _validDate(date, "xs:gMonthDay")) ||
+			(oDate = _validDate(date, "xs:gMonth")) ||
+			(oDate = _validDate(date, "xs:gDay"))
+			){
+			return _formatDate(oDate, "xs:dateTime");
+		}
+	}else{
+		if (oDate = _validDate(date, inFormat))
+         return _formatDate(oDate, dfName);
+		else
+			return '';
+	}
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>secondInMinute</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function secondInMinute(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+		    (oDate = _validDate(arguments[0], "xs:time"))
+		   )
+			return oDate.getSeconds();
+		else
+			return Number.NaN;
+	}else
+		return new Date().getSeconds();
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>seconds</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function seconds(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date")) ||
+			(oDate = _validDate(arguments[0], "xs:gYearMonth")) ||
+			(oDate = _validDate(arguments[0], "xs:gYear"))
+			)
+			return oDate.valueOf()/1000;
+		else 
+			if (oDate = _validDuration(arguments[0]))
+				return oDate.Seconds();
+			else
+				return Number.NaN;
+	}else
+		return Math.floor(new Date().valueOf()/1000);//current local date/time
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>sum</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="durations" type="node-set" default="''" optional="no"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function sum(ctx){
+	var sDate = "P0S";
+	if (typeof(ctx) == "object"){
+		if (ctx.length){
+			for (var i=0; i < ctx.length; i++){
+				ctxN  = ctx.item(i);
+				if (ctxN.nodeType == 1){
+					if (!(sDate = addDuration(sDate, _wander(ctxN))))
+						return '';
+				}
+				if (ctxN.nodeType == 2){
+					if (!(sDate = addDuration(sDate, ctxN.nodeValue)))
+						return '';
+				}
+			}
+		}else{
+			if (!(sDate = addDuration(sDate, ctx.nodeValue)))
+					return '';
+		}
+	}else{
+		return '';
+	}
+	return sDate;
+}
+function   _wander(ctx){
+	var sDate = "P0S";
+	for (var i=0; i < ctx.childNodes.length; i++){
+		ctxN = ctx.childNodes[i];
+		switch(ctxN.nodeType){
+			case 1:
+				if (!(sDate = addDuration(sDate, _wander(ctxN))))
+						return '';
+				break;
+			case 3:
+				if (!(sDate = addDuration(sDate, ctxN.nodeValue)))
+						return '';
+				break;
+			default:
+				break;
+		}
+	}
+	return sDate;
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>time</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="string" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function time(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime"))||
+			(oDate = _validDate(arguments[0], "xs:time"))
+		)
+			return _formatDate(oDate, "xs:time");
+		else
+			return '';
+	}else
+		return _formatDate(new Date(), "xs:time");
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>weekInMonth</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function weekInMonth(){
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date"))
+			)
+			return _weekInMonth(oDate, arguments[1], arguments[2]);
+		else
+			return Number.NaN;
+	}else
+		return _weekInMonth(new Date(), arguments[1], arguments[2]);	
+}
+function _weekInMonth(oDate, dfName, ctx){
+	var fdow = 0;
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectSingleNode(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/@first-day-of-week");
+		if (nodes != null)
+			fdow = gaDayNames[nodes.nodeValue];
+	}
+	var f = new Date(oDate);
+	f.setDate(1)
+	var fd = f.getDay()-1;
+	var dt = oDate.getDate() + fd - fdow;
+	return Math.floor((dt)/7)+1;
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>weekInYear</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="date-format" type="string" default="''" optional="yes"></doc:arg>
+		<doc:arg name="context" type="context" default="null" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function weekInYear(){
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date"))
+			)
+			return _weekInYear(oDate, arguments[1], arguments[2]);
+	}else 
+		return _weekInYear(new Date());
+	return '';
+}
+function _weekInYear(oDate, dfName, ctx){
+	var fdow = 0;
+	if (ctx != null){
+		var nodes = ctx.nextNode.selectSingleNode(
+			"//*[local-name()='date-format' and namespace-uri()='http://exslt.org/dates-and-times' and @name='" + dfName +"' ]" +
+			"/@first-day-of-week");
+		if (nodes != null)
+			fdow = gaDayNames[nodes.nodeValue];
+		return Math.ceil(_dayInYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate()+(7-fdow)) / 7);
+	}else
+		return Math.ceil(_dayInYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate()) / 7);
+}
+/**
+<doc:function date="2001-06-12">
+	<doc:name>year</doc:name>
+	<doc:version>2.0</doc:version>
+	<doc:return type="number" />
+	<doc:args>
+		<doc:arg name="date" type="string" default="''" optional="yes"></doc:arg>
+	</doc:args>
+</doc:function>
+**/
+function year(){//
+	if (arguments.length > 0){
+		var oDate;
+		if ((oDate = _validDate(arguments[0], "xs:dateTime")) ||
+			(oDate = _validDate(arguments[0], "xs:date")) ||
+			(oDate = _validDate(arguments[0], "xs:gYearMonth")) ||
+			(oDate = _validDate(arguments[0], "xs:gYear"))
+		    )
+			return oDate.getFullYear();
+		else
+			return Number.NaN;
+	}else
+		return new Date().getFullYear();
+}
+/**
+Private functions.
+**/
+function _validDate(date, format){
+	var parts;
+	var oDate = new Date(-62135596800000); // Mon Jan 1 00:00:00 UTC 1
+	switch(format){
+		case "xs:dateTime": //(CCYY-MM-DDThh:mm:ss)
+			var re = new RegExp("^([0-9]{4})-([0-9]{2})-([0-9]{2})(T([0-9]{2})(:([0-9]{2})(:([0-9]{2}))?)?)?(Z)?([\+\-][0-9]{2}:[0-9]{2})?$");
+			if (parts=re.exec(date)){
+				if (parts[10] == "Z"){
+					oDate.setFullYear(parts[1], parts[2]-1, parts[3]);
+					oDate.setHours(parts[5], parts[7], parts[9]);
+					oDate.setMinutes(oDate.getMinutes()-oDate.getTimezoneOffset());
+					gsSuppliedFormat = "xs:dateTime";
+					return oDate;
+				}else{
+					oDate.setFullYear(parts[1], parts[2]-1, parts[3]);
+					oDate.setHours(parts[5], parts[7], parts[9]);
+					gsSuppliedFormat = "xs:dateTime";
+					return oDate;
+				}
+			}
+			break;
+		case "xs:date": //(CCYY-MM-DD) 
+			var re = new RegExp("^([0-9]{4})-([0-9]{2})-([0-9]{2})$");
+			if (parts=re.exec(date)){
+				oDate.setFullYear(parts[1], parts[2]-1, parts[3]);
+				gsSuppliedFormat = "xs:date";
+				return oDate;
+			}
+			break;
+		case "xs:time": //(hh:mm:ss)
+			var re = new RegExp("^([0-9]{2})(:([0-9]{2})(:([0-9]{2}))?)?(Z)?$");
+			if (parts=re.exec(date)){
+				if (parts[9] == "Z"){
+					oDate.setHours(parts[1], parts[3], parts[5]);
+					oDate.setMinutes(oDate.getMinutes()-oDate.getTimezoneOffset());
+					gsSuppliedFormat = "xs:time";
+					return oDate;
+				}else{
+					oDate.setHours(parts[1], parts[3], parts[5]);
+					gsSuppliedFormat = "xs:time";
+					return oDate;
+				}
+			}
+			break;
+		case "xs:gYearMonth": //(CCYY-MM)
+			var re = new RegExp("^([0-9]{4})-([0-9]{2})$");
+			if (parts=re.exec(date)){
+				oDate.setFullYear(parts[1], parts[2]-1);
+				gsSuppliedFormat = "xs:gYearMonth";
+				return oDate;
+			}
+			break;
+		case "xs:gYear": //(CCYY)
+			var re = new RegExp("^([0-9]{4})$");
+			if (parts=re.exec(date)){
+				oDate.setFullYear(parts[1]);
+				gsSuppliedFormat = "xs:gYear";
+				return oDate;
+			}
+			break;
+		case "xs:gMonthDay": //(^--MM-DD)
+			var re = new RegExp("--([0-9]{2})-([0-9]{2})");
+			if (parts=re.exec(date)){
+				oDate.setMonth(parts[1]-1, parts[2]);
+				gsSuppliedFormat = "xs:gMonthDay";
+				return oDate;
+			}
+			break;
+		case "xs:gMonth": //(--MM--)
+			var re = new RegExp("^--([0-9]{2})--$");
+			if (parts=re.exec(date)){
+				oDate.setMonth(parts[1]-1);
+				gsSuppliedFormat = "xs:gMonth";
+				return oDate;
+			}
+			break;
+		case "xs:gDay": //(---DD)
+			var re = new RegExp("^---([0-9]{2})$");
+			if (parts=re.exec(date)){
+				oDate.setDate(parts[1]);
+				gsSuppliedFormat = "xs:gDay";
+				return oDate;
+			}
+			break;
+		default:
+			// format string 
+			var Z = "";
+			for (var i=0,j=0; i < format.length & oDate.toString() != "NaN";){
+				var s = j;
+				switch(format.substr(i, 1)){
+					case "G"://        era designator          (Text)              AD
+						while (format.substr(i, 1)=="G"){i++;j++;}
+						j++;
+						if (date.substr(s,j-s) == "BC" || date.substr(s,j-s) == "bc"){
+							oDate.setFullYear(-oDate.getFullYear);
+						}
+						break;
+					case "y"://        year                    (Number)            1996
+						while (format.substr(i, 1)=="y"){i++;j++;}
+						oDate.setYear(date.substr(s,j-s));
+						break;
+					case "M"://        month in year           (Text &amp; Number)     July &amp; 07
+						while (format.substr(i, 1)=="M"){i++;j++;}
+						if (i-s <= 2){
+							oDate.setMonth(date.substr(s,j-s)-1);
+						}else{
+							oDate.setMonth(_monthNumber(date.substr(s,j-s)));
+						}
+						break;
+					case "d"://        day in month            (Number)            10
+						while (format.substr(i, 1)=="d"){i++;j++;}
+						oDate.setDate(date.substr(s,j-s));
+						break;
+					case "h"://        hour in am/pm (1~12)    (Number)            12
+						while (format.substr(i, 1)=="h"){i++;j++;}
+						oDate.setHours(date.substr(s,j-s));
+						break;
+					case "H"://        hour in day (0~23)      (Number)            0
+						while (format.substr(i, 1)=="H"){i++;j++;}
+						oDate.setHours(date.substr(s,j-s));
+						break;
+					case "m"://        minute in hour          (Number)            30
+						while (format.substr(i, 1)=="m"){i++;j++;}
+						oDate.setMinutes(date.substr(s,j-s));
+						break;
+					case "s"://        second in minute        (Number)            55
+						while (format.substr(i, 1)=="s"){i++;j++;}
+						oDate.setSeconds(date.substr(s,j-s));
+						break;
+					case "S"://        millisecond             (Number)            978
+						while (format.substr(i, 1)=="S"){i++;j++;}
+						oDate.setMilliseconds(date.substr(s,j-s));
+						break;
+					case "E"://        day in week             (Text)              Tuesday
+						while (format.substr(i, 1)=="E"){i++;j++;}
+						while (format.substr(i+1, 1)!=date.substr(j, 1)){j++;}
+						break;
+					case "D"://        day in year             (Number)            189
+						while (format.substr(i, 1)=="D"){i++;j++;}
+						while (format.substr(i+1, 1)!=date.substr(j, 1)){j++;}
+						break;
+					case "F"://        day of week in month    (Number)            2 (2nd Wed in July)
+						while (format.substr(i, 1)=="F"){i++;j++;}
+						break;
+					case "w"://        week in year            (Number)            27
+						while (format.substr(i, 1)=="w"){i++;j++;}
+						while (format.substr(i+1, 1)!=date.substr(j, 1)){j++;}
+						break;
+					case "W"://        week in month           (Number)            2
+						while (format.substr(i, 1)=="W"){i++;j++;}
+						while (format.substr(i+1, 1)!=date.substr(j, 1)){j++;}
+						break;
+					case "a"://        am/pm marker            (Text)              PM
+						while (format.substr(i, 1)=="a"){i++;j++;}
+						j++;
+						if (date.substr(s,j-s) == "PM" || date.substr(s,j-s) == "pm")
+							oDate.setHours(oDate.getHours()+12);
+						break;
+					case "k"://        hour in day (1~24)      (Number)            24
+						while (format.substr(i, 1)=="k"){i++;j++;}
+						oDate.setHours(date.substr(s,j-s));
+						break;
+					case "K"://        hour in am/pm (0~11)    (Number)            0
+						while (format.substr(i, 1)=="K"){i++;j++;}
+						oDate.setHours(date.substr(s,j-s));
+						break;
+					case "z"://        time zone               (Text)              Pacific Standard Time
+						while (format.substr(i, 1)=="z"){i++;j++;}
+						while (format.substr(i+1, 1)!=date.substr(j, 1)){j++;}
+						//oDate.setMinutes(oDate.getMinutes() - oDate.getTimezoneOffset());
+						Z = date.substr(s,j-s);
+ 						break;
+ 					case "'"://        escape for text         (Delimiter)
+ 						if (format.substr(i+1, 1) == "'"){
+ 							i+=2;
+ 						}else{
+ 							i++;
+ 							while (format.substr(i, 1)!="'"){i++;j++;}
+ 							i++;
+ 						}
+ 						break;
+					default:
+						if (format.substr(i, 1) != date.substr(j, 1)){
+							return false;
+						}
+						i++;j++;
+						break;
+				}
+			}
+			if (j < date.length)
+				return false;
+			if (oDate.toString() != "NaN"){
+				if (Z != ""){
+					var re = new RegExp("([\+\-][0-9]{2})?:([0-9]{2})?");
+					if (parts=re.exec(Z)){
+						// check GMT/BST
+						var tzo = parts[1]*60 + parts[2];
+						//if (tzo != new Date().getTimezoneOffset()){
+						//	oDate.setMinutes(oDate.getMinutes() - (oDate.getTimezoneOffset() - tzo))
+						//}
+					}
+				}
+				gsSuppliedFormat = "custom";
+				return oDate;
+			}
+			break;
+	}
+	return false;
+}
+function _formatDate(oDate, format){
+	if (oDate == Number.NaN)return Number.NaN;
+	switch(format){
+		case "xs:dateTime": //(CCYY-MM-DDThh:mm:ss)
+			var tzo = oDate.getTimezoneOffset(); 
+			return oDate.getFullYear() + "-" + pad(oDate.getMonth()+1) + "-" + pad(oDate.getDate()) + "T" +
+				   pad(oDate.getHours()) + ":" + pad(oDate.getMinutes()) + ":" + pad(oDate.getSeconds()) + (tzo < 0?"-":"+") + pad(Math.abs(tzo/60)) + ":" + pad(tzo % 60);
+			break;
+		case "xs:date": //(CCYY-MM-DD) 
+			return oDate.getFullYear() + "-" + pad(oDate.getMonth()+1) + "-" + pad(oDate.getDate());
+			break;
+		case "xs:time": //(hh:mm:ss)
+			var tzo = oDate.getTimezoneOffset(); 
+			return pad(oDate.getHours()) + ":" + pad(oDate.getMinutes()) + ":" + pad(oDate.getSeconds()) + (tzo < 0?"-":"+") + pad(Math.abs(tzo/60)) + ":" + pad(tzo % 60);
+			break;
+		case "xs:gYearMonth": //(CCYY-MM)
+			return oDate.getFullYear() + "-" + pad(oDate.getMonth()+1);
+			break;
+		case "xs:gYear": //(CCYY)
+			return oDate.getFullYear();
+			break;
+		case "xs:gMonthDay": //(--MM-DD)
+			return pad(oDate.getMonth() + 1) + "-" + pad(oDate.getDate());
+			break;
+		case "xs:gMonth": //(--MM--)
+			return pad(oDate.getMonth()+1);
+			break;
+		case "xs:gDay": //(---DD)
+			return pad(oDate.getDate());
+			break;
+	}
+	return false;
+}
+function pad(v){
+	return (v<10?"0"+v:v);
+}
+
+function _validDuration(d){
+        var parts;
+        var re = new RegExp("^([\-])?P(([0-9]+)Y)?(([0-9]+)M)?(([0-9]+)D)?((T)?(([0-9]+)H)?(([0-9]+)M)?((([0-9]+)(\.([0-9]+))?)S)?)?$");
+        if (parts = re.exec(d)){
+                if ((/T$/.exec(d)) || (parts[9] == "T" && parts[11]+parts[13]+parts[16]+parts[18]== ""))// ~(:+(|) duh!!!
+                        return Number.NaN;
+                return new Duration(parts[1], parts[3], parts[5], parts[7], parts[11], parts[13], parts[16], parts[18]);
+        }
+        return Number.NaN;
+}
+
+function Duration(pm, years, months, days, hours, minutes, seconds, fraction){
+	this.pm = pm;
+	this.years = years*1;
+	this.months = months*1;
+	this.days = days*1;
+	this.hours = hours*1;
+	this.minutes = minutes*1;
+	this.seconds = seconds*1;
+	this.fraction = fraction*1;
+	this.milliseconds = eval('0.'+fraction) * 100;
+	this.mask = ((this.years?1:0)<<6) + ((this.months?1:0)<<5) + ((this.days?1:0)<<4) + ((this.hours?1:0)<<3) + ((this.minutes?1:0)<<2) + ((this.seconds?1:0)<<1) + (this.milliseconds?1:0);
+	this.addDate = function(d){d.setFullYear(eval(this.pm+this.years)+d.getFullYear(),eval(this.pm+this.months)+d.getMonth(),eval(this.pm+this.days)+d.getDate());d.setHours(eval(this.pm+this.hours)+d.getHours(),eval(this.pm+this.minutes)+d.getMinutes(),eval(this.pm+this.seconds)+d.getSeconds());d.setMilliseconds(eval(this.pm+this.milliseconds));return d;}
+	this.Seconds = function(){if (this.years || this.months)return Number.NaN;return this.days*giDayMill + this.hours*giHourMill + this.minutes*giMinMill + this.seconds*giSecMill;}
+}
+var giYearMill = 31536000000;
+var giMonthMill = 2592000000;
+var giDayMill = 86400000;
+var giHourMill = 3600000;
+var giMinMill = 60000;
+var giSecMill = 1000;
+function _formatDuration(du){
+	if (typeof(du) == "object"){
+		var pm = du.pm;
+		var y = du.years;
+		var m = du.months;
+		var d = du.days;
+		var h = du.hours;
+		var n = du.minutes;
+		var s = du.seconds + du.milliseconds/1000;
+		
+		if (y+m+d+h+n+s == 0)
+			return 'P0S';
+		return pm + "P" + 
+				(y!=0?y + "Y":'') + 
+				(m!=0?m + "M":'') + 
+				(d!=0?d + "D":'') + 
+				(h+n+s!=0?"T":'') +
+				(h!=0?h + "H":'') + 
+				(n!=0?n + "M":'') + 
+				(s!=0?s + "S":'');
+	}else{
+		var pm = (du<0?'-':'');
+		du = Math.abs(du);
+		var d = Math.floor((du) / giDayMill);
+		var h = Math.floor((du % giDayMill) / giHourMill);
+		var n = Math.floor((du % giHourMill) / giMinMill);
+		var s = Math.floor((du % giMinMill) / giSecMill) + (du % giSecMill)/1000;
+		return pm + "P" + 
+				(d!=0?d + "D":'') + 
+				(h+n+s!=0?"T":'') +
+				(h!=0?h + "H":'') + 
+				(n!=0?n + "M":'') + 
+				(s!=0?s + "S":'');
+	}
+}
Index: /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.difference.html
===================================================================
--- /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.difference.html (revision 296)
+++ /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.difference.html (revision 296)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE html
+  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "/schema/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml"><head><title>EXSLT - date:difference - Implementer Page</title><link rel="stylesheet" href="base.css"/></head><body><h1 id="#title"><a href="http://www.exslt.org/">EXSLT</a> - <a href="http://www.exslt.org/date">date</a>:<a href="http://www.exslt.org/date/functions/difference">difference</a> - Implementer Page</h1><table><tr><td id="menu"><p class="level1"><a href="index.html">User Page</a></p><p class="level1"><a href="../../../howto.html">How To</a></p><p class="level1"><a href="../../../download.html">Downloads</a></p><p class="level1">Modules</p><p class="level2"><a href="../../../date/date.html">Dates and Times</a></p><p class="level3"><a href="../../functions/add/date.add.html">date:add()</a></p><p class="level3"><a href="../../functions/add-duration/date.add-duration.html">date:add-duration()</a></p><p class="level3"><a href="../../functions/date/date.date.html">date:date()</a></p><p class="level3"><a href="../../functions/date-time/date.date-time.html">date:date-time()</a></p><p class="level3"><a href="../../functions/day-abbreviation/date.day-abbreviation.html">date:day-abbreviation()</a></p><p class="level3"><a href="../../functions/day-in-month/date.day-in-month.html">date:day-in-month()</a></p><p class="level3"><a href="../../functions/day-in-week/date.day-in-week.html">date:day-in-week()</a></p><p class="level3"><a href="../../functions/day-in-year/date.day-in-year.html">date:day-in-year()</a></p><p class="level3"><a href="../../functions/day-name/date.day-name.html">date:day-name()</a></p><p class="level3"><a href="../../functions/day-of-week-in-month/date.day-of-week-in-month.html">date:day-of-week-in-month()</a></p><p class="level3"><a href="../../functions/difference/date.difference.html">date:difference()</a></p><p class="level3"><a href="../../functions/duration/date.duration.html">date:duration()</a></p><p class="level3"><a href="../../functions/format-date/date.format-date.html">date:format-date()</a></p><p class="level3"><a href="../../functions/hour-in-day/date.hour-in-day.html">date:hour-in-day()</a></p><p class="level3"><a href="../../functions/leap-year/date.leap-year.html">date:leap-year()</a></p><p class="level3"><a href="../../functions/minute-in-hour/date.minute-in-hour.html">date:minute-in-hour()</a></p><p class="level3"><a href="../../functions/month-abbreviation/date.month-abbreviation.html">date:month-abbreviation()</a></p><p class="level3"><a href="../../functions/month-in-year/date.month-in-year.html">date:month-in-year()</a></p><p class="level3"><a href="../../functions/month-name/date.month-name.html">date:month-name()</a></p><p class="level3"><a href="../../functions/parse-date/date.parse-date.html">date:parse-date()</a></p><p class="level3"><a href="../../functions/second-in-minute/date.second-in-minute.html">date:second-in-minute()</a></p><p class="level3"><a href="../../functions/seconds/date.seconds.html">date:seconds()</a></p><p class="level3"><a href="../../functions/sum/date.sum.html">date:sum()</a></p><p class="level3"><a href="../../functions/time/date.time.html">date:time()</a></p><p class="level3"><a href="../../functions/week-in-month/date.week-in-month.html">date:week-in-month()</a></p><p class="level3"><a href="../../functions/week-in-year/date.week-in-year.html">date:week-in-year()</a></p><p class="level3"><a href="../../functions/year/date.year.html">date:year()</a></p><p class="level3"><a href="../../elements/date-format/date.date-format.html">date:date-format</a></p><p class="level2"><a href="../../../dyn/dyn.html">Dynamic</a></p><p class="level2"><a href="../../../exsl/exsl.html">Common</a></p><p class="level2"><a href="../../../func/func.html">Functions</a></p><p class="level2"><a href="../../../math/math.html">Math</a></p><p class="level2"><a href="../../../random/random.html">Random</a></p><p class="level2"><a href="../../../regexp/regexp.html">Regular Expressions</a></p><p class="level2"><a href="../../../set/set.html">Sets</a></p><p class="level2"><a href="../../../str/str.html">Strings</a></p><p class="level1"><a href="../../../submissions/">Submissions</a></p><p class="level1"><a href="../../../list">Mailing List</a></p><p class="level1"><a href="../../../contact.html">Contact</a></p></td><td id="content"><p><b>Version: </b>1<br/><b>Status: </b>implemented<br/><b>User Page: </b><a href="index.html">index.html</a><br/><b>XML Definition: </b><a href="date.difference.xml">date.difference.xml</a><br/><b>Function Package: </b><a href="date.difference.zip">date.difference.zip</a></p><h4>Function Syntax</h4><pre><var>string</var> <b>date:difference</b>(<var>string</var>, <var>string</var>)</pre><h4>Template Syntax</h4><pre>&lt;xsl:call-template name="<b>date:difference</b>"&gt;
+   &lt;xsl:with-param name="start" select="<var>string</var>" /&gt;
+   &lt;xsl:with-param name="end" select="<var>string</var>" /&gt;
+&lt;/xsl:call-template&gt;</pre><div><p>
+         The <code>date:difference</code> function returns the duration between the first date and the second date.  If the first date occurs before the second date, then the result is a positive duration; if it occurs after the second date, the result is a negative duration.
+      </p><p>
+         The two dates must both be right-truncated date/time strings in one of the formats defined in [<a href="http://www.w3.org/TR/xmlschema-2/" class="offsite">XML Schema Part 2: Datatypes</a>].  The date/time with the most specific format (i.e. the least truncation) is converted into the same format as the date with the most specific format (i.e. the most truncation).  The permitted formats are as follows, from most specific to least specific:
+      </p><ul><li><a href="http://www.w3.org/TR/xmlschema-2/#dateTime" class="offsite"><code>xs:dateTime</code></a> (<code><var>CCYY</var>-<var>MM</var>-<var>DD</var>T<var>hh</var>:<var>mm</var>:<var>ss</var></code>)
+         </li><li><a href="http://www.w3.org/TR/xmlschema-2/#date" class="offsite"><code>xs:date</code></a> (<code><var>CCYY</var>-<var>MM</var>-<var>DD</var></code>)
+         </li><li><a href="http://www.w3.org/TR/xmlschema-2/#gYearMonth" class="offsite"><code>xs:gYearMonth</code></a> (<code><var>CCYY</var>-<var>MM</var></code>)
+         </li><li><a href="http://www.w3.org/TR/xmlschema-2/#gYear" class="offsite"><code>xs:gYear</code></a> (<code><var>CCYY</var></code>)
+         </li></ul><p>
+         If either of the arguments is not in one of these formats, <code>date:difference</code> returns the empty string (<code>''</code>).
+      </p><p>
+         The difference between the date/times is returned as a string in the format defined for <code>xs:duration</code> in [<a href="http://www.w3.org/TR/xmlschema-2/#duration" class="offsite">3.2.6 duration</a>] of [<a href="http://www.w3.org/TR/xmlschema-2/" class="offsite">XML Schema Part 2: Datatypes</a>].
+      </p><p>
+         If the date/time string with the least specific format is in either <code>xs:gYearMonth</code> or <code>xs:gYear</code> format, then the number of days, hours, minutes and seconds in the duration string must be equal to zero.  (The format of the string will be <code>P<var>n</var>Y<var>n</var>M</code>.)  The number of months specified in the duration must be less than 12.
+      </p><p>
+         Otherwise, the number of years and months in the duration string must be equal to zero.  (The format of the string will be <code>P<var>n</var>DT<var>n</var>H<var>n</var>M<var>n</var>S</code>.)  The number of seconds specified in the duration string must be less than 60; the number of minutes must be less than 60; the number of hours must be less than 24.
+      </p></div><p>
+      An implementation of this extension 
+      function
+      in the EXSLT date namespace must conform to the behaviour described in this document.
+   </p><h2>Implementations</h2><p>
+            Built-in support for <code>date:difference</code> is available in the following XSLT processors:
+         </p><table><tr><th class="rowhead">Processor</th><th>Processor Version</th><th>Implemented Version</th></tr><tr><td class="rowhead"><a href="http://4Suite.org">4XSLT, from 4Suite.</a></td><td>0.12.0a3</td><td>1</td></tr><tr><td class="rowhead"><a href="http://xmlsoft.org/XSLT/">libxslt from Daniel Veillard et al.</a></td><td>1.0.19</td><td>1</td></tr></table><p>
+            The following implementations of <code>date:difference</code> are available:
+         </p><table><tr><th class="rowhead">Language</th><th>Implemented Version</th><th>Creator</th><th>Date</th><th>Download</th></tr><tr><td class="rowhead"><a href="date.difference.function.xsl.html">EXSLT Function</a></td><td>1</td><td><a href="mailto:mail@jenitennison.com">Jeni Tennison</a></td><td>2001-05-12</td><td><a href="date.difference.function.xsl">date.difference.function.xsl</a></td></tr><tr><td class="rowhead"><a href="date.difference.template.xsl.html">XSLT Template</a></td><td>1</td><td><a href="mailto:mail@jenitennison.com">Jeni Tennison</a></td><td>2001-05-12</td><td><a href="date.difference.template.xsl">date.difference.template.xsl</a></td></tr><tr><td class="rowhead"><a href="date.js.html">Javascript</a></td><td>1</td><td><a href="mailto:chris@bayes.co.uk">Chris Bayes</a></td><td>2001-06-11</td><td><a href="date.js">date.js</a></td></tr><tr><td class="rowhead"><a href="date.msxsl.xsl.html">Msxsl</a></td><td>1</td><td><a href="mailto:chris@bayes.co.uk">Chris Bayes</a></td><td>2001-06-16</td><td><a href="date.msxsl.xsl">date.msxsl.xsl</a></td></tr></table><h2>Change History</h2><p><b>Submitted: </b>2001-05-12<br/><b>Creator: </b><a href="mailto:mail@jenitennison.com">Jeni Tennison</a>(<a href="http://www.jenitennison.com/">http://www.jenitennison.com/</a>)</p><p><dc:description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exslt="http://exslt.org/documentation">
+            Returns the difference between two dates as a duration.
+         </dc:description></p><table><tr><th class="rowhead">Version</th><th>Modified</th><th>By</th><th>Details</th></tr><tr><td class="rowhead">1.1</td><td style="width: 5em;">2001-06-11</td><td><a href="mailto:mail@jenitennison.com">Jeni Tennison</a></td><td style="text-align: left;"><p><dc:description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exslt="http://exslt.org/documentation">
+            Added implementations in Javascript, XSLT and EXSLT - Functions.
+         </dc:description></p></td></tr><tr><td class="rowhead">1.2</td><td style="width: 5em;">2001-06-16</td><td><a href="mailto:mail@jenitennison.com">Jeni Tennison</a></td><td style="text-align: left;"><dc:description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exslt="http://exslt.org/documentation"><ul><li>Updated Javascript implementation.</li><li>Added Microsoft-specific stylesheet.</li></ul></dc:description></td></tr><tr><td class="rowhead">1.3</td><td style="width: 5em;">2002-08-21</td><td><a href="mailto:craig.stewart@nottingham.ac.uk">Craig Stewart</a></td><td style="text-align: left;"><p><dc:description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exslt="http://exslt.org/documentation">Added 4XSLT and libxslt implementation to the list.</dc:description></p></td></tr><tr><td class="rowhead">1.4</td><td style="width: 5em;">2002-11-12</td><td><a href="mailto:craig.stewart@nottingham.ac.uk">Craig Stewart</a></td><td style="text-align: left;"><p><dc:description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:exslt="http://exslt.org/documentation">Updated 4XSLT version to 0.12.0a3.</dc:description></p></td></tr></table></td></tr></table><div id="colophon"><p><a href="http://www.exslt.org/date/functions/difference/date.difference.html">http://www.exslt.org/date/functions/difference/date.difference.html</a> last modified 2002-11-12</p></div></body></html>
Index: /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/index.html
===================================================================
--- /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/index.html (revision 296)
+++ /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/index.html (revision 296)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE html
+  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "/schema/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml"><head><title>EXSLT - date:difference</title><link rel="stylesheet" href="base.css"/></head><body><h1 id="#title"><a href="http://www.exslt.org/">EXSLT</a> - <a href="http://www.exslt.org/date">date</a>:<a href="http://www.exslt.org/date/functions/difference">difference</a></h1><table><tr><td id="menu"><p class="level1"><a href="date.difference.html">Implementer Page</a></p><p class="level1"><a href="../../../howto.html">How To</a></p><p class="level1"><a href="../../../download.html">Downloads</a></p><p class="level1">Modules</p><p class="level2"><a href="../../../date/index.html">Dates and Times</a></p><p class="level3"><a href="../../functions/add/index.html">date:add()</a></p><p class="level3"><a href="../../functions/add-duration/index.html">date:add-duration()</a></p><p class="level3"><a href="../../functions/date/index.html">date:date()</a></p><p class="level3"><a href="../../functions/date-time/index.html">date:date-time()</a></p><p class="level3"><a href="../../functions/day-abbreviation/index.html">date:day-abbreviation()</a></p><p class="level3"><a href="../../functions/day-in-month/index.html">date:day-in-month()</a></p><p class="level3"><a href="../../functions/day-in-week/index.html">date:day-in-week()</a></p><p class="level3"><a href="../../functions/day-in-year/index.html">date:day-in-year()</a></p><p class="level3"><a href="../../functions/day-name/index.html">date:day-name()</a></p><p class="level3"><a href="../../functions/day-of-week-in-month/index.html">date:day-of-week-in-month()</a></p><p class="level3"><a href="../../functions/difference/index.html">date:difference()</a></p><p class="level3"><a href="../../functions/duration/index.html">date:duration()</a></p><p class="level3"><a href="../../functions/format-date/index.html">date:format-date()</a></p><p class="level3"><a href="../../functions/hour-in-day/index.html">date:hour-in-day()</a></p><p class="level3"><a href="../../functions/leap-year/index.html">date:leap-year()</a></p><p class="level3"><a href="../../functions/minute-in-hour/index.html">date:minute-in-hour()</a></p><p class="level3"><a href="../../functions/month-abbreviation/index.html">date:month-abbreviation()</a></p><p class="level3"><a href="../../functions/month-in-year/index.html">date:month-in-year()</a></p><p class="level3"><a href="../../functions/month-name/index.html">date:month-name()</a></p><p class="level3"><a href="../../functions/parse-date/index.html">date:parse-date()</a></p><p class="level3"><a href="../../functions/second-in-minute/index.html">date:second-in-minute()</a></p><p class="level3"><a href="../../functions/seconds/index.html">date:seconds()</a></p><p class="level3"><a href="../../functions/sum/index.html">date:sum()</a></p><p class="level3"><a href="../../functions/time/index.html">date:time()</a></p><p class="level3"><a href="../../functions/week-in-month/index.html">date:week-in-month()</a></p><p class="level3"><a href="../../functions/week-in-year/index.html">date:week-in-year()</a></p><p class="level3"><a href="../../functions/year/index.html">date:year()</a></p><p class="level3"><a href="../../elements/date-format/index.html">date:date-format</a></p><p class="level2"><a href="../../../dyn/index.html">Dynamic</a></p><p class="level2"><a href="../../../exsl/index.html">Common</a></p><p class="level2"><a href="../../../func/index.html">Functions</a></p><p class="level2"><a href="../../../math/index.html">Math</a></p><p class="level2"><a href="../../../random/index.html">Random</a></p><p class="level2"><a href="../../../regexp/index.html">Regular Expressions</a></p><p class="level2"><a href="../../../set/index.html">Sets</a></p><p class="level2"><a href="../../../str/index.html">Strings</a></p><p class="level1"><a href="../../../submissions/">Submissions</a></p><p class="level1"><a href="../../../list">Mailing List</a></p><p class="level1"><a href="../../../contact.html">Contact</a></p></td><td id="content"><p><b>Implementer Page: </b><a href="date.difference.html">date.difference.html</a><br/><b>Function Package: </b><a href="date.difference.zip">date.difference.zip</a></p><h4>Function Syntax</h4><pre><var>string</var> <b>date:difference</b>(<var>string</var>, <var>string</var>)</pre><h4>Template Syntax</h4><pre>&lt;xsl:call-template name="<b>date:difference</b>"&gt;
+   &lt;xsl:with-param name="start" select="<var>string</var>" /&gt;
+   &lt;xsl:with-param name="end" select="<var>string</var>" /&gt;
+&lt;/xsl:call-template&gt;</pre><div><p>
+         The <code>date:difference</code> function returns the duration between the first date and the second date.  If the first date occurs before the second date, then the result is a positive duration; if it occurs after the second date, the result is a negative duration.
+      </p><p>
+         The two dates must both be right-truncated date/time strings in one of the formats defined in [<a href="http://www.w3.org/TR/xmlschema-2/" class="offsite">XML Schema Part 2: Datatypes</a>].  The date/time with the most specific format (i.e. the least truncation) is converted into the same format as the date with the most specific format (i.e. the most truncation).  The permitted formats are as follows, from most specific to least specific:
+      </p><ul><li><a href="http://www.w3.org/TR/xmlschema-2/#dateTime" class="offsite"><code>xs:dateTime</code></a> (<code><var>CCYY</var>-<var>MM</var>-<var>DD</var>T<var>hh</var>:<var>mm</var>:<var>ss</var></code>)
+         </li><li><a href="http://www.w3.org/TR/xmlschema-2/#date" class="offsite"><code>xs:date</code></a> (<code><var>CCYY</var>-<var>MM</var>-<var>DD</var></code>)
+         </li><li><a href="http://www.w3.org/TR/xmlschema-2/#gYearMonth" class="offsite"><code>xs:gYearMonth</code></a> (<code><var>CCYY</var>-<var>MM</var></code>)
+         </li><li><a href="http://www.w3.org/TR/xmlschema-2/#gYear" class="offsite"><code>xs:gYear</code></a> (<code><var>CCYY</var></code>)
+         </li></ul><p>
+         If either of the arguments is not in one of these formats, <code>date:difference</code> returns the empty string (<code>''</code>).
+      </p><p>
+         The difference between the date/times is returned as a string in the format defined for <code>xs:duration</code> in [<a href="http://www.w3.org/TR/xmlschema-2/#duration" class="offsite">3.2.6 duration</a>] of [<a href="http://www.w3.org/TR/xmlschema-2/" class="offsite">XML Schema Part 2: Datatypes</a>].
+      </p><p>
+         If the date/time string with the least specific format is in either <code>xs:gYearMonth</code> or <code>xs:gYear</code> format, then the number of days, hours, minutes and seconds in the duration string must be equal to zero.  (The format of the string will be <code>P<var>n</var>Y<var>n</var>M</code>.)  The number of months specified in the duration must be less than 12.
+      </p><p>
+         Otherwise, the number of years and months in the duration string must be equal to zero.  (The format of the string will be <code>P<var>n</var>DT<var>n</var>H<var>n</var>M<var>n</var>S</code>.)  The number of seconds specified in the duration string must be less than 60; the number of minutes must be less than 60; the number of hours must be less than 24.
+      </p></div><h2>Implementations</h2><p>
+                  The following XSLT processors support <code>date:difference</code>:
+               </p><ul><li><a href="http://4Suite.org">4XSLT, from 4Suite.</a> (version 0.12.0a3)</li><li><a href="http://xmlsoft.org/XSLT/">libxslt from Daniel Veillard et al.</a> (version 1.0.19)</li></ul><p>
+                  Implementations of <code>date:difference</code> are available in the following languages:
+               </p><ul><li><a href="date.difference.function.xsl">EXSLT Function</a> (by <a href="mailto:mail@jenitennison.com">Jeni Tennison</a>)</li><li><a href="date.difference.template.xsl">XSLT Template</a> (by <a href="mailto:mail@jenitennison.com">Jeni Tennison</a>)</li><li><a href="date.js">Javascript</a> (by <a href="mailto:chris@bayes.co.uk">Chris Bayes</a>)</li><li><a href="date.msxsl.xsl">Msxsl</a> (by <a href="mailto:chris@bayes.co.uk">Chris Bayes</a>)</li></ul></td></tr></table><div id="colophon"><p><a href="http://www.exslt.org/date/functions/difference/index.html">http://www.exslt.org/date/functions/difference/index.html</a> last modified 2002-11-12</p></div></body></html>
Index: /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.difference.xsl
===================================================================
--- /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.difference.xsl (revision 296)
+++ /projects/DailyDrillingReport_1.2/Deliveries/HTMLreport/difference/date.difference.xsl (revision 296)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:func="http://exslt.org/functions" xmlns:date="http://exslt.org/dates and times" version="1.0" extension-element-prefixes="date" date:doc="http://www.exslt.org/date">
+   <import href="date.difference.function.xsl"/>
+   <import href="date.difference.template.xsl"/>
+   <func:script language="exslt:javascript" implements-prefix="date" src="date.js"/>
+   <func:script language="exslt:msxsl" implements-prefix="date" src="date.msxsl.xsl"/>
+</stylesheet>
