David Jacob
David Jacob

Reputation: 213

Windows Phone 7 - I want to get daylight savings offset via programming

I want to have one feature in my windows phone application where i will require to see if for the time zone whether the daylight settings is currently on or off. I can get this detail for the time zone which is set in my phone, but what i want is that i can get this for any time zone i pass or set.

For example, if i pass time zone "Antarctica/Palmer", i should able to find whether currently daylight setting is on or off. I tried few things but not able to find anything. I do not want to use any web api to give me this.

Is there any facility where i can set the timezone via code to get the result and then revert it back to original or some other solution?

Thanks.

Upvotes: 0

Views: 188

Answers (2)

ChrisF
ChrisF

Reputation: 137178

There's the IsDaylightSavingTime method:

Indicates whether a specified date and time falls in the range of daylight saving time for the time zone of the current TimeZoneInfo object.

It requires you to have a TimeZoneInfo object, but you indicate that you already have that.

Upvotes: 1

Jon Skeet
Jon Skeet

Reputation: 1502656

For example, if i pass time zone "Antarctica/Palmer", i should able to find whether currently daylight setting is on or off.

That looks like a zoneinfo/tzdb/Olsen time zone ID to me, not one that Windows in general uses. My Noda Time project uses tzdb and would be able to get you that information, but we don't currently build a Silverlight version - we probably could with a bit of work, but it wouldn't be trivial. Patches would be welcome, of course...

Do you definitely want to use tzdb IDs, or would the appropriate Windows ID be okay for you? Unfortunately TimeZoneInfo.FindSystemTimeZoneById appears not to be supported on Silverlight :(

Upvotes: 0

Related Questions