danielchalmers / DesktopClock

A digital clock for your desktop!
https://github.com/danielchalmers
MIT License
137 stars 33 forks source link

Time from internet #47

Closed Skimmenthal13 closed 3 months ago

Skimmenthal13 commented 6 months ago

Hi, Thank you for your tool is very nice! I need to take date time from internet and not from my pc. My pc takes date time from comany's server and it is uncorrect and also i can't change this setting. It would be nice having this feature in your tool! It's only an idea but i think could be useful to other people.

I have already modified the code taking time from this function

public static DateTime GetNistTime() { var myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://www.microsoft.com"); var response = myHttpWebRequest.GetResponse(); string todaysDates = response.Headers["date"]; return DateTime.ParseExact(todaysDates, "ddd, dd MMM yyyy HH:mm:ss 'GMT'", CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.AssumeUniversal);
}

I modified the code to satisfied my needs but to integrate this function as a configurable feature it's a littel bit harder :)

Thanks!

breem42 commented 6 months ago

Hi, Thank you for your tool is very nice! I need to take date time from internet and not from my pc. My pc takes date time from comany's server and it is uncorrect and also i can't change this setting. It would be nice having this feature in your tool! It's only an idea but i think could be useful to other people.

I have already modified the code taking time from this function

public static DateTime GetNistTime() { var myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://www.microsoft.com"); var response = myHttpWebRequest.GetResponse(); string todaysDates = response.Headers["date"]; return DateTime.ParseExact(todaysDates, "ddd, dd MMM yyyy HH:mm:ss 'GMT'", CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.AssumeUniversal); }

I modified the code to satisfied my needs but to integrate this function as a configurable feature it's a littel bit harder :)

Thanks!

Although I would not use this feature, I think it's a great idea, and if it's as easy as it seems, go for it!