Topic
• 5 replies
• Latest Post - ‏2013-01-09T09:38:05Z by HermannSW
6772 Posts

# Pinned topic Why is dp:time-value() a xs:double instead of xs:long?

‏2013-01-07T16:34:49Z |
From the doc, dp:time-value() returns xs:double.

Isn't xs:double a floating point number? Why doesn't dp:time-value() return xs:long instead? Is there a way to convert it to a long that is compatible with an epoch timestamp?

Thanks.
Updated on 2013-01-09T09:38:05Z at 2013-01-09T09:38:05Z by HermannSW
• HermannSW
7450 Posts

#### Re: Why is dp:time-value() a xs:double instead of xs:long?

‏2013-01-08T16:05:57Z
Hi,

> From the doc, dp:time-value() returns xs:double.
>
http://pic.dhe.ibm.com/infocenter/wsdatap/v5r0m0/index.jsp?topic=%2Fcom.ibm.dp.xi.doc%2Fextensionfunctions84.htm

> Isn't xs:double a floating point number?
>
Yes, but in XSLT 1.0 xs:double is the number type, there is no other, see:
https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/xslt_number_precision21

xs:double provides 15 digit integer precision which is far more than needed for epoch, even in millisecond resolution
(the maximum representable time is 2038-01-19 for 2^31-1=2147483647 seconds, or 2.147.483.647.000 milliseconds).

> Why doesn't dp:time-value() return xs:long instead?
>
xs:long is no XSLT 1.0 datatype.

> Is there a way to convert it to a long that is compatible with an epoch timestamp?
>
You do not need to convert -- its precise as at is.

Posting now explains the 4 methods to determine "now" on DataPower:
https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/now37

Hermann<myXsltBlog/> <myXsltTweets/>
6772 Posts

#### Re: Why is dp:time-value() a xs:double instead of xs:long?

‏2013-01-08T16:36:02Z
Thanks
6772 Posts

#### Re: Why is dp:time-value() a xs:double instead of xs:long?

‏2013-01-08T19:23:06Z
One more question. I assume dp:time-value() returns milliseconds since epoch in GMT, right?

Thanks.
6772 Posts

#### Re: Why is dp:time-value() a xs:double instead of xs:long?

‏2013-01-08T19:25:17Z
One more question. I assume dp:time-value() returns milliseconds since epoch in GMT, right?

Thanks.
Sorry. Missed your last link which explains that it is GMT (UTC).

Thanks.
• HermannSW
7450 Posts

#### Re: Why is dp:time-value() a xs:double instead of xs:long?

‏2013-01-09T09:38:05Z
Sorry. Missed your last link which explains that it is GMT (UTC).

Thanks.
Maybe this thread on millisecond resolution of timestamps with handling different time zones might be interesting: