for a certain programming job I have in mind, I need to log some data and write it to a file. I've got that part but I needed to find a way to get the system time. After ages of searchin I managed to find a method that i could understand and used it. Heres the problem: The date of part of the code seems to work ok, with it working. But when the time is displayed, the hour value is one lower than my system time. eg. at 18:00 the time is 17:00 I remembered about daylight saving times but I would have thought that it would read directly from my time (which is correct). I just want to know whether you get the same result or whether its just some freak anomaly with my PC. Heres an example exe which just displays time (sorry about the file size still not sorted that out)
I get 18:47 as well, so one hour behind. What are you using to do this sort of thing? I'm taking a course @ College next year, but would like a headstart lol.
Its in C++ and I'm using Dev-C++ latest version (www.bloodshed.net). I guessed that would be it, but I'm having some headache's on how to predict daylight saving time, and leap years make things harder again. Bugger this I'm going for a shower and some food.
Yea it is, but the problem comes when daylight saving times aren't like that anymore. The clocks go forward on a different date each year, and I don't know how to write an algorithm to predict the date. Maybe something like: if (date.wMonth == 4 && date.wDay >= /*date of clocks go forward*/) { if (date.wMonth == 10 && date.wDay >= /*date of clocks go back*/) /*hour variable*/ = date.wHour + 1; } But I don't know the dates which they change since the dates change each year.
Its ok now I fixed it. Just ended up using a totally different function, reads the time ok now. The function gets the same job done and puts it into a character array, making it much easier for me to manipulate and it tells the time correctly while only using a small fraction of code than the other inaccurate complicated one.