|
|
#1 (permalink) Top |
|
The King
![]() ![]() Join Date: Jan 2004
Age: 18 Male
Posts: 5,255
Times Helpful: 403
My Mood: Drunk
Status: Offline
|
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)
__________________
Never trust a program you don't have the source code for. ![]() My website | Powerful Desktop Linux | Linux for human beings | Linux for power users | Linux for ricers |
|
|
|
|
#2 (permalink) Top |
|
Alpha Geek
![]() Join Date: Apr 2004
Age: 20 Male
Posts: 2,270
Times Helpful: 51
My Mood: Angelic
Status: Offline
|
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. |
|
|
|
|
#3 (permalink) Top |
|
The King
![]() ![]() Join Date: Jan 2004
Age: 18 Male
Posts: 5,255
Times Helpful: 403
My Mood: Drunk
Status: Offline
|
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.
__________________
Never trust a program you don't have the source code for. ![]() My website | Powerful Desktop Linux | Linux for human beings | Linux for power users | Linux for ricers |
|
|
|
|
#4 (permalink) Top |
|
Administrator
![]() Join Date: Oct 2001
Age: 24 Male
Posts: 4,420
Times Helpful: 116
My Mood: Bored
Status: Offline
|
Is it not possible just to add one hour to the time? time + 1 hour? I get the same btw.
__________________
Zone 365 | F@H Team | Team Stats | Use The Thank You System | My Groups: Manchester United | Apple |
|
|
|
|
#5 (permalink) Top |
|
The King
![]() ![]() Join Date: Jan 2004
Age: 18 Male
Posts: 5,255
Times Helpful: 403
My Mood: Drunk
Status: Offline
|
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.
__________________
Never trust a program you don't have the source code for. ![]() My website | Powerful Desktop Linux | Linux for human beings | Linux for power users | Linux for ricers |
|
|
|
|
#6 (permalink) Top |
|
The King
![]() ![]() Join Date: Jan 2004
Age: 18 Male
Posts: 5,255
Times Helpful: 403
My Mood: Drunk
Status: Offline
|
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.
__________________
Never trust a program you don't have the source code for. ![]() My website | Powerful Desktop Linux | Linux for human beings | Linux for power users | Linux for ricers |
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Just a tidbit for you people in the UK | Fred | PC Gaming | 6 | 19-03-2005 07:25 PM |
| 101 Ways to annoy people | Nic | General Chat | 2 | 19-03-2005 06:20 PM |
| Whasssa matta people? Can'tca read? | Egaladeist | General Chat | 2 | 20-11-2004 11:23 PM |