Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 18th, 2009, 10:51 AM
Authorized User
 
Join Date: May 2007
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default Handling DST dates

I am trying to determine the total number of minutes from the start of the day until the <date> value. For example, if the 00 hour of the current date was:

Case 1:
basedate: 2010-11-07T00:00:00.000-06:00

<date>2010-11-07T01:00:00.000-05:00</date> //should return 00 min
<date>2010-11-07T01:00:00.000-06:00</date> //should return 60 min


Case 2:
basedate: 2010-11-07T00:00:00.000-05:00

<date>2010-11-07T01:00:00.000-05:00</date> //should return 60 min
<date>2010-11-07T01:00:00.000-06:00</date> //should return 120 min

My two questions are:

1. Is there a way to capture the current dateTime and reset the object to the 00 hour?

2. Once I have a base dateTime set at the 00 hour of the current day, I am able to take the difference of the base dateTime and the <date> value, but is there a way to calculate the total minutes of that difference? All I can think of is to use built in functions to get the hours, multiple by 60 and add the minutes. I just wasn't sure if there was a more efficient method.

Any help is greatly appreciated.
 
Old December 18th, 2009, 11:06 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>I am trying to determine the total number of minutes from the start of the day until the <date> value

That looks like ($date2 - $date1) div xs:dayTimeDuration('PT1M')

I assume that makes your other questions irrelevant.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old December 18th, 2009, 11:22 AM
Authorized User
 
Join Date: May 2007
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks!

I do still have the open question, is it possible to capture the base dateTime by capturing the current-dateTime() and then change the time to 00:00:00 -5:00 using built-in XSLT functions? I looked at the spec, but couldn't find the magic bullet.
 
Old December 18th, 2009, 11:48 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Does xs:date(current-dateTime()) give you what you want?
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old December 18th, 2009, 11:52 AM
Authorized User
 
Join Date: May 2007
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wouldn't I then have to cast it back as a dateTime to get:

2009-18-12T00:00:00.000-06:00

and use that value for dateTime comparisons?

I will give it a try. Thanks!





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to determine whether a date falls in Day Light Saving Time (DST) smandeh XSLT 2 November 5th, 2009 11:04 AM
dates again dhoward VB.NET 2002/2003 Basics 12 August 22nd, 2007 09:48 AM
DST schedule job failed. khautinh SQL Server DTS 3 December 23rd, 2004 03:59 PM
between dates capitala Access VBA 1 May 30th, 2004 05:20 PM
Handling Null Dates [email protected] ASP.NET 1.0 and 1.1 Professional 12 February 27th, 2004 07:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.