IsDaylightSavingTime .NET 1.1 vs 2.0

  • Thread starter Thread starter doomsday123
  • Start date Start date
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();
}
 
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
 
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/
 
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
 
Back
Top