IsDaylightSavingTime .NET 1.1 vs 2.0

D

doomsday123

Will

private bool IsDST(DateTime d)
{
return System.TimeZone.IsDaylightSavingTime(d,
System.TimeZone.CurrentTimeZone.GetDaylightChanges(d.Year));
}

in .NET 1.1 return the same thing as this in .NET 2.0?

private bool IsDST(DateTime d)
{
//convert time to local and check for daylight savings
return d.ToLocalTime().IsDaylightSavingTime();
}
 
D

doomsday123

Ok so I did some local testing and it seems like they do return the
same thing if you pass the same DateTime into them. Now I just need to
find a solution that will work the same way for JAVA
 
J

Jon Skeet [C# MVP]

Ok so I did some local testing and it seems like they do return the
same thing if you pass the same DateTime into them. Now I just need to
find a solution that will work the same way for JAVA

Java (not JAVA, btw) has completely different date/time handling to
..NET. If you find it hard work (the API can be a bit clumsy) there's a
library you might find useful called Joda:

http://joda-time.sourceforge.net/
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Ok so I did some local testing and it seems like they do return the
same thing if you pass the same DateTime into them. Now I just need to
find a solution that will work the same way for JAVA

Untested:

boolean isDST(Date d) {
return TimeZone.getDefault().inDaylightTime(d):
}

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top