How to convert GMT time to local time? 
Author Message
 How to convert GMT time to local time?

Hi, I have a problem of converting GMT time to local time (for any given
country).  The GMT time is in a character string of the form "yydddhhmmss",
say "96123102345" stands for the 123rd day of 1996 at 10:23:45.  And I also
have the country to whose local time I want the GMT time to be converted.
For example, I have the above GMT time string and the country is Japan.  How
can I convert the GMT time to Japan's local time?   And I need to do it for
many different countries.  Thanks a lot for your help!



Fri, 08 Jan 1999 03:00:00 GMT  
 How to convert GMT time to local time?

Quote:

> Hi, I have a problem of converting GMT time to local time (for any given
> country).  The GMT time is in a character string of the form "yydddhhmmss",
> say "96123102345" stands for the 123rd day of 1996 at 10:23:45.  And I also
> have the country to whose local time I want the GMT time to be converted.
> For example, I have the above GMT time string and the country is Japan.  How
> can I convert the GMT time to Japan's local time?   And I need to do it for
> many different countries.  Thanks a lot for your help!

I did actually do this a few years ago. Unforetunately, the code is now residing
in a company about 200 miles away, so I can't send it to you.

It is quite simple, a few things to remember though:-

India is a pain. It is the only country in the world that has a 1/2 hour in
it's difference from GMT. I think it is 3.5 hours, everywhere else is measured
in hours... Apologies to all the Indians out there ;-)

Leap years are a bit weird. It works along the lines of every four years is.
But, every 200 years isn't. Or something like that. Anyway the year 2000 is NOT
a leap year.

I assume that you are dealing with GPS recievers or something llike that, so
you should take into account leap seconds. Every so often, they add in an extra
second just to confuse everyone, ie you will get 59, 60, 00. Be careful.

Needless to say, you have to carry mins, hours, days, months etc.

You might try getting in touch with one of the GPS satellite newsgroups, it
has been a long time since I looked at them. Try asking very nicely at
sci.geo.satellite.nav

Rob.



Sun, 10 Jan 1999 03:00:00 GMT  
 How to convert GMT time to local time?

Quote:

> Leap years are a bit weird. It works along the lines of every four years is.
> But, every 200 years isn't. Or something like that.

Every four years is. Except, every hundred years isn't. Except, every four
hundred years is.

Quote:
> Anyway the year 2000 is NOT a leap year.

Precisely wrong. The year 2000 *will* be a leap year. (It's divisible by
four hundred.) See http://www.ast.cam.ac.uk/pubinfo/leaflets/ for
information from the Royal Greenwhich Observatory.

Cheers

Jon
____
\  //   Jon Ribbens     //



Sun, 10 Jan 1999 03:00:00 GMT  
 How to convert GMT time to local time?

[I have problem with my news server, so I've not the whole thread;
please excuse me if I repeat what someone else have already said]

Quote:


> > Hi, I have a problem of converting GMT time to local time (for any given
> > country).  The GMT time is in a character string of the form "yydddhhmmss",
> > say "96123102345" stands for the 123rd day of 1996 at 10:23:45.  And I also
> > have the country to whose local time I want the GMT time to be converted.
> > For example, I have the above GMT time string and the country is Japan.  How
> > can I convert the GMT time to Japan's local time?   And I need to do it for
> > many different countries.  Thanks a lot for your help!

Take a look at the timezone package, at <ftp://elsie.nci.nih.edu/pub>.
It contains a full replacement of the <time.h> management functions with acurate and
up-to-date handling of local times offset, including daylight saving time policies.

Then, take the mktime() code, and changed it to handle your particular format of
datas.  The obvious way of inputting tm_year=96, tm_mon=0, tm_day=123 and the hour
given above doesn't work, because mktime() hopes a localtime, not an UTC time
(official name for GMT since 1972, BTW).  But you can achieve the result by dropping
the code which handle the localtime to UTC time conversion, near the end of mktime().

<snip>

Quote:

> India is a pain. It is the only country in the world that has a 1/2 hour in
> it's difference from GMT.

Oh no it isn't the only.  BTW, Nepal is "worse", with a 3/4 hour delta with UTC.
Apologizes to Nepalians for the "worse", of course.

Quote:
> I think it is 3.5 hours, everywhere else is measured
> in hours... Apologies to all the Indians out there ;-)

India is +0530 (that is, 5,5 hours ahead of UTC).
Afghanistan is +0330, Nepal is +0545, etc..

Quote:

> Leap years are a bit weird. It works along the lines of every four years is.
> But, every 200 years isn't. Or something like that. Anyway the year 2000 is NOT
> a leap year.

#define isleapyear(x)   ( (x)%4 == 0 && ( (x)%100 != 0 || (x)%400 == 0 ) )

Works for the Gregorian calendar only.

<snip>

Hope it helps.

Antoine LECA



Mon, 11 Jan 1999 03:00:00 GMT  
 How to convert GMT time to local time?



Quote:

>> Hi, I have a problem of converting GMT time to local time (for any given
>> country).  The GMT time is in a character string of the form "yydddhhmmss",
>> say "96123102345" stands for the 123rd day of 1996 at 10:23:45.  And I also
>> have the country to whose local time I want the GMT time to be converted.
>> For example, I have the above GMT time string and the country is Japan.  How
>> can I convert the GMT time to Japan's local time?   And I need to do it for
>> many different countries.  Thanks a lot for your help!

>I did actually do this a few years ago. Unforetunately, the code is now residing
>in a company about 200 miles away, so I can't send it to you.

>It is quite simple, a few things to remember though:-

>India is a pain. It is the only country in the world that has a 1/2 hour in
>it's difference from GMT.

Apart from Australia of course.  I don't know whether there are any others.

[snip]

Quote:
>Leap years are a bit weird. It works along the lines of every four years is.
>But, every 200 years isn't. Or something like that. Anyway the year 2000 is NOT
>a leap year.

Oh no, not again.  The year 2000 *is* a leap year.

End of thread - please, please, please!

John
--
John Winters.  Wallingford, Oxon, England.



Mon, 11 Jan 1999 03:00:00 GMT  
 How to convert GMT time to local time?


Quote:
>India is a pain. It is the only country in the world that has a 1/2 hour in
>it's difference from GMT. I think it is 3.5 hours, everywhere else is measured
>in hours... Apologies to all the Indians out there ;-)

Actually, there are several other such instances, including Newfoundland.
There is at least one country on a 15-minute difference, and Saudi Arabia
still insists on using local solar time, so that the difference from GMT
depends on the exact longitude.  (I don't recall whether they have bent so far
as to use mean solar time, or whether they actually reset their clocks daily
in accordance with the analemma.)

Quote:
>Leap years are a bit weird. It works along the lines of every four years is.
>But, every 200 years isn't. Or something like that. Anyway the year 2000 is NOT
>a leap year.

Wrong twice, I'm afraid.  It is a leap year if
  it is divisible by 4,
    unless divisible by 100,
      unless divisible by 400,
        unless divisible by 4000 (this last is relatively new).
2000 _will_ _be_ a leap year, although 1900 was not (a common source of errors
on IBM mainframes, where the zero is Midnight, January 1, 1900, GMT).


Mon, 11 Jan 1999 03:00:00 GMT  
 How to convert GMT time to local time?

Quote:
> > Leap years are a bit weird. It works along the lines of every four years is.
> > But, every 200 years isn't. Or something like that. Anyway the year 2000
> is NOT
> > a leap year.

Here is the leap year rule:
It's a leap year if it's divisible by 4, unless it's divisible by 100. In
the latter case, it's not a leap year unless it's also divisible by 400

This says 1900 is not a leap year, but 2000 is.



Tue, 12 Jan 1999 03:00:00 GMT  
 How to convert GMT time to local time?


Quote:


> > Hi, I have a problem of converting GMT time to local time (for any given
> > country).  The GMT time is in a character string of the form "yydddhhmmss",
> > say "96123102345" stands for the 123rd day of 1996 at 10:23:45.  And I also
> > have the country to whose local time I want the GMT time to be converted.
> > For example, I have the above GMT time string and the country is Japan.  How
> > can I convert the GMT time to Japan's local time?   And I need to do it for
> > many different countries.  Thanks a lot for your help!

> I did actually do this a few years ago. Unforetunately, the code is now
residing
> in a company about 200 miles away, so I can't send it to you.

> It is quite simple, a few things to remember though:-

> India is a pain. It is the only country in the world that has a 1/2 hour in
> it's difference from GMT. I think it is 3.5 hours, everywhere else is measured
> in hours... Apologies to all the Indians out there ;-)

The middle of Austrailia is a 1/2 hour time zone (last I knew!)

Quote:

> Leap years are a bit weird. It works along the lines of every four years is.
> But, every 200 years isn't. Or something like that. Anyway the year 2000
is NOT
> a leap year.

Don't start this argument again.  The year 2000 IS (repeat IS) a leap
year.  If you are interested in the past and the long term future, 1900
wasn't and 2100 won't be.  Please get your facts correct.  You will
probably get lots of flak on this subject.

Quote:

> I assume that you are dealing with GPS recievers or something llike that, so
> you should take into account leap seconds. Every so often, they add in
an extra
> second just to confuse everyone, ie you will get 59, 60, 00. Be careful.

Yes, GPS receviers have leap seconds in them.  A good place to look for
references to all time, past and present is:
http://tycho.usno.navy.mil
Explains quite a few things.  Even has a map of world time zones.  Pretty
good too!!

Quote:

> Needless to say, you have to carry mins, hours, days, months etc.

> You might try getting in touch with one of the GPS satellite newsgroups, it
> has been a long time since I looked at them. Try asking very nicely at
> sci.geo.satellite.nav

> Rob.

--
Tom Watson



Tue, 12 Jan 1999 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. How to convert local time to gmt using a local variable time zone per process/thread

2. Convert local time to gmt time without using TimeZone Env variable

3. GMT time and Local time ?

4. Q: How to convert GMT to local time?

5. Converting GMT to local time

6. How to convert local time with specific time zone to UTC time in Win32 API

7. Converting UTC time to local time

8. converting from Local Time to UTC time...

9. GMT to local time conv

10. time confusion. I want time now GMT

11. howDoI convert a time from GMT to PST

12. Converting VARIANT DATE to GreenwichMean Time (GMT) or LocalTime

 

 
Powered by phpBB® Forum Software