I would like to check if any specified timezone (other than my local time zone) is in DST or not.
To check if the local time zone is currently DST I am using:
Dim today_date As Date = Now.Date
Msgbox(today_date.IsDaylightSavingTime())
I would like to check if other time zones ("A.U.S. Eastern Standard Time" and "New Zealand Standard Time") are in DST according to today's date.
So what I have so far:
Dim AusZoneId As String = "A.U.S. Eastern Standard Time"
Dim AusZone As TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(AusZoneId)
MsgBox(AusZone.SupportsDaylightSavingTime)
'Established True or False if TZ supported DST
What I want to do is feed in a date (eg today) and see if this date according to AUS Eastern Standard time is in DST.
You shouldn't do it for a date, as that can be ambiguous (the start of the day in standard time and the end of the day in daylight time, or vice versa) but instead ask whether a specific point in time is in daylight time:
Dim zoneId As String = "AUS Eastern Standard Time";
Dim zone As TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(zoneId)
Dim dst As Boolean = zone.IsDaylightSavingTime(DateTime.UtcNow)
(Or use some other point in time, of course.) I'd strongly encourage you to pass in a DateTime
with a Kind
of Utc
.
See more on this question at Stackoverflow