Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 2nd, 2008, 04:02 PM
Authorized User
 
Join Date: May 2008
Location: , , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anboss
Default millisec or fraction of seconds

this is a question regarding the time that the date-time function returns:

2008-05-07T11:24:35.876-04:00

the "876" here is the milli-seconds value or it is fractional seconds.
Reply With Quote
  #2 (permalink)  
Old June 2nd, 2008, 04:20 PM
mhkay's Avatar
Wrox Author
Points: 17,773, Level: 58
Points: 17,773, Level: 58 Points: 17,773, Level: 58 Points: 17,773, Level: 58
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,839
Thanks: 0
Thanked 267 Times in 262 Posts
Default

Well, if there's three digits then it's both. The actual number of digits you get back after the decimal point is system-dependent, so it's best to treat it as fractional seconds.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old June 2nd, 2008, 04:41 PM
Authorized User
 
Join Date: May 2008
Location: , , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anboss
Default

So now if the date template returns

2008-05-30T20:42:01.9249999523162842Z,

if i keep three numbers after '.' and truncate rest, will it be the required millisecond value?

2008-05-30T20:42:01.924Z

if not how to convert this fractional seconds to milli seconds?
Reply With Quote
  #4 (permalink)  
Old June 2nd, 2008, 05:00 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

It will be wrong by approximately 0.999952 of a millisecond.

In other words, it will be off by almost a full millisecond.

Do you care???

If not, leave it alone.

If you care, then you should round the number instead of just truncate.
Reply With Quote
  #5 (permalink)  
Old June 2nd, 2008, 05:09 PM
mhkay's Avatar
Wrox Author
Points: 17,773, Level: 58
Points: 17,773, Level: 58 Points: 17,773, Level: 58 Points: 17,773, Level: 58
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,839
Thanks: 0
Thanked 267 Times in 262 Posts
Default

I am very confused by your question. There are 1000 milliseconds in a second, so 1 second and 543 milliseconds is 1.534 seconds. What exactly is your problem?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #6 (permalink)  
Old June 2nd, 2008, 05:11 PM
Authorized User
 
Join Date: May 2008
Location: , , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anboss
Default

mhkay:

well milliseconds can never have value more than 999. but what we see is 15 numbers. also 1.500 is the same as "1 min and 500 milliseconds" or "1 min and 5 milliseconds"

as an analogy: 1.5 years would mean 1 year and 6 months rather than 1 year and 5 months.


Old Pedant:

if i do round off, then i may have to manipulate the seconds/hours/or even date part.

For eg:

2008-05-30T23:59:59.9999999523162842Z

this date time value will make me do lot of string manipulation work.
(am i right?)

my requirement is 3 digits after the seconds part. and this should represent milliseconds. if there is a way to format this time stamp value so that just 3 digits are returned for the frac seconds part. so that i can readily consider this as milliseconds.
Reply With Quote
  #7 (permalink)  
Old June 2nd, 2008, 05:30 PM
mhkay's Avatar
Wrox Author
Points: 17,773, Level: 58
Points: 17,773, Level: 58 Points: 17,773, Level: 58 Points: 17,773, Level: 58
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,839
Thanks: 0
Thanked 267 Times in 262 Posts
Default

If it really matters to you to round to the nearest millisecond rather than truncating, try format-dateTime($d,'[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01]:[f001]')

However, it's highly unlikely that the value returned by the system is sufficiently precise that it really makes a meaningful difference whether you round or truncate the value.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #8 (permalink)  
Old June 2nd, 2008, 07:34 PM
Authorized User
 
Join Date: May 2008
Location: , , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anboss
Default

Thanks Kay...

in our XI50 SOA appliance, the format-dateTime function is not supported unfortunately :(... what to do?
if you can give me the code of the format-dateTime template, i will try to import the same in my xsl.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
to add three seconds MunishBhatia C# 2005 2 October 9th, 2007 08:29 AM
wait for seconds pzmrcd C# 1 August 1st, 2007 03:06 PM
seconds-from-duration outspaced XSLT 2 April 3rd, 2007 09:51 AM
Converting Seconds into Nano seconds and viceversa chandu80 General .NET 0 June 4th, 2005 02:18 AM
redirect after 2 seconds groupmatch BOOK: ASP.NET Website Programming Problem-Design-Solution 3 October 26th, 2004 05:44 PM



All times are GMT -4. The time now is 03:35 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.