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 November 5th, 2009, 10:42 AM
Authorized User
 
Join Date: Mar 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to determine whether a date falls in Day Light Saving Time (DST)

I need to determine in XSLT 1.0 whether or not a date falls between Day Light Saving Time. For example: if the given date is 04/20/2008, I need to programmatically determine whether the date falls between the second sunday in March and the first Sunday in November.

DST_BEGIN: Second Sunday in March of every year
DST_END: First Sunday in November of every year

If I can get the DST_BEGIN date and DST_END date then I can do the comparison to determine whether or not a given date falls between DST time using these two dates.

Any help will be appreciated.

Thanks,
Scott
 
Old November 5th, 2009, 10:59 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Obviously this can only be done if you know what country you are in (you seem to be giving US examples), and for dates in the past (national governments, or in some cases state governments, can change the clocks on a whim).

There are no standard faciities in XSLT 1.0 or 2.0 for this. You may be able to call extension functions in an external library. Saxon has an extension function saxon:in-summer-time() which would appear to meet your needs: see

http://www.saxonica.com/documentatio...mmer-time.html

It takes two arguments, the date/time in question, and an identifier for the civil time zone - either simply a country code, or an Olsen timezone name.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old November 5th, 2009, 11:04 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

(Incidentally, you might be wondering why I called it in-summer-time() rather than in-daylight-savings-time(). One reason is that I'm British, and that's what we call it here. The main reason though is that daylight-savings is typical government-speak. They are telling us to get up an hour earlier in the morning, but they pretend that they are giving us more hours of sunshine in the day.)
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Determine the first day of the current Fiscal Year tcarnahan Oracle 3 February 16th, 2009 09:52 PM
writing time of a day nasirmunir PHP How-To 1 December 17th, 2008 06:51 PM
time zone & day light time rajn ASP.NET 1.0 and 1.1 Professional 0 August 7th, 2007 05:02 PM
how to get the day from a given date pherms Classic ASP Basics 2 April 16th, 2004 05:38 PM





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