Reputation: 3162
I need to set my system's time zone automatically using location. when I travel to some other places my system time zone will remains same.When I open my WPF Application and if the internet is connected, is it possible to automatically set the time zone of my system by getting the current time zone by location?
Upvotes: 1
Views: 979
Reputation: 241778
You would need to
Have a reliable source of location information.
Pass the coordinates determined in step 1 to one of these techniques to get an IANA time zone.
Translate the IANA time zone to a Windows time zone using CLDR mappings, as described here.
Set the Windows time zone using one of the approaches from this answer.
Explain to your users why your application is doing something that is really their own responsibility (or the operating system's responsibility). In other words, don't be sneaky about this. If you're going to do it, it should be a prominent feature of your application, and you should have the user's confirmation before changing anything. Remember, the time zone setting is global for the machine, not just for your application.
IMHO, if this isn't a system utility you're writing, then you should just use the determined time zone instead of trying to set the system to it.
Upvotes: 1
Reputation: 89
Step one: you need to get the users location I suggest HostIP
Step two: get the time zone of that location Google maps time zone API
then you have to stitch those together.
Upvotes: 0