One-liner to determine daylight saving time

Powershell MVP Mike F Robbins, the winner of the Scripting Games 2013 posted the following function to determine daylight saving time.

As he said, this is only valid in the US. I wondered what it would look like in my time zone.

I knew there’s an official page that uses a registry based approach on this page kb914387
I also knew that there are .Net classes that can be used, see for example this post

I didn’t know how to read the TZI (time zone information) from the registry until I landed on the following MSDN page

Reading the registry seems complicated and there’s actually a buried .Net method for this purpose.

2007..2019 | % { [System.TimeZone]::CurrentTimeZone.GetDaylightChanges($_) }

In my timezone, it look likes 😀


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.