Followers

Sunday, 30 April 2017

Pulling time and date from the internet

Source: codereview.stackexchange.com --- Saturday, April 29, 2017
I'm pulling the time and date from the internet because when the user turns the Raspberry Pi off, it loses its date and time settings and unfortunately Windows 10 IoT is very slow to correct it. I have tried to use the DateTime method, however, I can't seem to work out how to create a Clock with a custom time and have it tick like as if i was to call DateTime.Now.ToShortTimeString(); (I'm not asking anyone to implement this). Here is the following code that will scrap the information I need and parse it. The code works, however, sometimes there is lag (I'm guessing because the RPI isn't all that powerful) resulting in the time sometimes missing a second due to it trying to catch up I guess. I'm not too worried about it being out by a couple of seconds however if you leave the program running on the Pi for a long period of time, it will end up being out by 20 mins to an hour depending on how long the application has been running. Here is the code that I have created in a console application to make it a little more neater and to show where I'm guessing the problem is and if there is a better way to complete my task at hand. class Program { struct TimeAndDate { public int hour; public int minute; public int second; public DateTime date; public bool completed; } static TimeAndDate timeAndDate; static Clock clock; static void Main(string[] args) { getTime(); Console.ReadLine(); DateTime.Now.ToShortTimeString(); } private static async ...



from Windows http://ift.tt/2qrA95V

No comments:

Post a Comment