Thread: question on how to get different time zone

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

    question on how to get different time zone

    Hi, just wondering if I have a program which accepts a string name such as "paris" or "tokyo", how would I use any of the function in the <time.h> to display the correct time as specified by the city name? thanks in advance.
    'The bigger they are, the harder they fall' ~Yang

  2. #2
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    I doubt u have a function to do that but you can get the time and use the time offset to get what u need...

  3. #3
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    Quote Originally Posted by godhand
    Hi, just wondering if I have a program which accepts a string name such as "paris" or "tokyo", how would I use any of the function in the <time.h> to display the correct time as specified by the city name? thanks in advance.
    Set up two arrays (or an array of struct) that contain the name and the time offset. Then use a time function to get a time structure. Add/subtract your time offset, fix any problems, convert to string and output.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  4. #4
    Registered User
    Join Date
    Jun 2003
    Posts
    31
    Hi, could you give me an example which uses the time offset to get the correct time zone please?
    'The bigger they are, the harder they fall' ~Yang

  5. #5
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    Never used it, but you might want to look into locale.h, it is standard, then get the "region" and then use a switch on what it returns or something. I have never used the header so don't even know if it is possible.
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    This is really simple. However, I'm not going to give you your answer, because you don't learn anything by having me do it for you. What is meant by an offset lookup is something like:
    Code:
    "Seattle", -8
    "New York", -5
    "London", 0
    Now those were all off of the top of my head, but they're fairly close to accurate if not entirely. The point is, you assign a value to a given city. This is the time difference. Thus, you look up where they are, where they want to compare to, and add do a little math.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Niche Question: real time stock quotes
    By keira in forum C Programming
    Replies: 0
    Last Post: 03-08-2008, 11:06 AM
  2. Help with assignment!
    By RVDFan85 in forum C++ Programming
    Replies: 12
    Last Post: 12-03-2006, 12:46 AM
  3. What is the best way to record a process execution time?
    By hanash in forum Linux Programming
    Replies: 7
    Last Post: 03-15-2006, 07:17 AM
  4. inputting time in separate compilation
    By sameintheend01 in forum C++ Programming
    Replies: 6
    Last Post: 03-13-2003, 04:33 AM
  5. time class
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-11-2001, 10:12 PM