Thread: help programming an analogue clock

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    31

    help programming an analogue clock

    Hi, I am trying to write an OpengGL program which displays the current time on an analouge clock interface. I have drawn the clock, but I have no idea how to implement function such as time(),gettimeofday() and ctime. Any tips or hints to get me started will be greatly appreciated.
    'The bigger they are, the harder they fall' ~Yang

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    i hate to just give out answers but i dont have time to explain right now so make sure you understand what is happening before you hit paste

    Code:
    #include <time.h>
    ...
    
    time_t curTime =  time(NULL);
    int hours = ((curTime / 3600) % 24) - 7;
    int mins  = (curTime / 60) % 60;
    int secs  = curTime % 60;

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    31
    "int hours = ((curTime / 3600) % 24) - 7;"

    this one gives weird number, for example, at 1 am now, it gave me 8?? What does it mean?
    'The bigger they are, the harder they fall' ~Yang

  4. #4
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Quote Originally Posted by godhand
    "int hours = ((curTime / 3600) % 24) - 7;"

    this one gives weird number, for example, at 1 am now, it gave me 8?? What does it mean?

    This comes down to the "understanding it before you use it" part. The number you get is MST. You'll have to adjust the offset for whatever time zone you want.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logical Error in Clock program
    By SVXX in forum C++ Programming
    Replies: 0
    Last Post: 05-10-2009, 12:12 AM
  2. Outside influences on clock cycles? (clock_t)
    By rsgysel in forum C Programming
    Replies: 4
    Last Post: 01-08-2009, 06:15 PM
  3. Clock Troubles
    By _Nate_ in forum C Programming
    Replies: 22
    Last Post: 06-19-2008, 05:15 AM
  4. clock program
    By bazzano in forum C Programming
    Replies: 3
    Last Post: 03-30-2007, 10:12 PM
  5. world clock
    By nevermind in forum C++ Programming
    Replies: 1
    Last Post: 10-23-2002, 07:45 AM