Qbasicnews.com
December 10, 2019, 08:46:05 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2 3 4
  Print  
Author Topic: Timezone calculator.  (Read 40570 times)
Moneo
Na_th_an
*****
Posts: 1971


« on: July 14, 2005, 10:01:33 PM »

My son is in Japan this week participating in a Robocup (robots that play soccer) competition. Anyway, we in the family have a tough time figuring out what date and time  it is over there. This made me think of a timezone calculator.

I haven't done it yet myself, but here are the requirements:
- Program written in QB or Quickbasic.
- Time always expressed in military time, example 17:30.
- Input timezones will be expressed as GMT +nn or GMT -nn.
- Dates formatted as mm/dd/yyyy.
- Input #1: the timezone, date and time that the user is in. This allows user to specify any date/time. Example: I will be in Singapore on 08/15/2005 at 10:00. What date/time will it be then in New York?
- Input #2: the timezone for which a date and time will be calculated based on the input.
- Perform adequate input validation.
- Output: the calculated timezone, date and time, plus the most important city in that timezone. Note: You determine the most important city.

NOTE: THE ABOVE SENTENCE WAS CORRECTED TO READ:
- Output: the calculated date and time for the timezone specified in Input #2, also displaying the city name for the timezone.

Considerations:
- You'll need to find the 24 time zones on the Internet. Refer to them as GMT +nn or GMT -nn. Also, assign the name of the most important city to each of the 24 timezones.
- Also on the Internet, you will have to find whether the most important city in each timezone is on daylight savings time or not.
NOTE: THE ABOVE DAYLIGHT SAVINGS TIME REQUIREMENT HAS BEEN SUSPENDED.

Please submit a complete working program, not just a function. I'll check every entry and provide feedback.
*****
Logged
DrV
Na_th_an
*****
Posts: 1553



WWW
« Reply #1 on: July 14, 2005, 10:24:37 PM »

It seems there are 25 integer time zones (this confuses me...) and various other non-integer time zones: http://wwp.greenwichmeantime.com/info/timezone.htm

Should only the 24/25 integer time zones be allowed, or should the nonstandard zones be taken into account also?
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #2 on: July 15, 2005, 03:29:16 PM »

Yeah, you're right.

It's the old "relative to zero" problem.

Quoting from your mentioned webpage:
"There are 25 integer World Time Zones from -12 through 0 (GMT) to +12."

So, we have to use a total of 25 timezones.
And, let's not use any of the non-standard ones.
*****
Logged
rpgfan3233
Ancient Guru
****
Posts: 617



« Reply #3 on: July 15, 2005, 03:40:50 PM »

Hmm. . . According to this board's settings, there are 26, from GMT-12 to GMT+13!? I'm thoroughly confused now. . . I could have sworn there were only 24 because GMT-12 and GMT+12 are the same. . .

Edit: At least, I THOUGHT they were. . .
Logged

974277320612072617420666C61696C21 (Hexadecimal for those who don't know)
Moneo
Na_th_an
*****
Posts: 1971


« Reply #4 on: July 15, 2005, 03:56:35 PM »

Quote from: "rpgfan3233"
Hmm. . . According to this board's settings, there are 26, from GMT-12 to GMT+13!? I'm thoroughly confused now. . . I could have sworn there were only 24 because GMT-12 and GMT+12 are the same. . .

Edit: At least, I THOUGHT they were. . .


Now I'm confused myself.
I'm going to check into this further.

In the meantime, would you guys kindly explore this issue and provide some more feedback.
*****
Logged
Deleter
Na_th_an
*****
Posts: 1292



WWW
« Reply #5 on: July 15, 2005, 07:13:25 PM »

http://en.wikipedia.org/wiki/Time_zones
lists all the time zones...some are :45 O_o
Logged

rpgfan3233
Ancient Guru
****
Posts: 617



« Reply #6 on: July 15, 2005, 08:43:07 PM »

After reading that article that Deleter provided (which was quite useful), it appears that there WERE 24 time zones, but some areas in certain time zones changed somehow. For example, UTC+14 was changed from UTC-10 by simply skipping 1994-12-31!! UTC+12 was created, changing from UTC-12, so really there are only 24 time zones: GMT-12 (UTC-12) to GMT+11 (UTC+11), despite these technicalities. For the sake of simplifying this challenge, I recommend we use just the 24.
Logged

974277320612072617420666C61696C21 (Hexadecimal for those who don't know)
Moneo
Na_th_an
*****
Posts: 1971


« Reply #7 on: July 15, 2005, 09:01:18 PM »

Boy, do we have a can of worms regarding timezones.

I consulted my Encyclopaedia Britannica and World Book Encyclopedia and they both define 24 standard timezones.

There are numerous exceptions, but for this challenge, we will use the 24 timezones on the following list. I have included principal country/city names.

Also for this challenge, we will ignore the issue of daylight savings or summer time. It becomes almost impossible for our program to determine if the subject timezome uses daylight savings, when it starts and ends, and whether it advances one hour or two. Therefore, we will leave this daylight time adjustment up to the user of the program.

TIMEZONES:
GMT = London
GMT - 1 = Reykjavik
GMT - 2 = Greenland
GMT - 3 = Rio de Janeiro, Brazil
GMT - 4 = Santiago de Chile
GMT - 5 = New York
GMT - 6 = Chicago
GMT - 7 = Denver
GMT - 8 = Seattle
GMT - 9 = Alaska
GMT -10 = Honolulu
GMT -11 = Midway Island
GMT -12  (does not exist, see GMT +12)

continuing in a circle around the world............
GMT +12 = New Zealand
GMT +11 = Solomon Islands
GMT +10 = Sydney
GMT + 9  = Tokyo
GMT + 8  = Hong Kong, and China
GMT + 7  = Bangkok
GMT + 6 =  Omsk, Russia
GMT + 5 =  Karachi
GMT + 4 = Stalingrad
GMT + 3 = Moscow
GMT + 2 = Cairo
GMT + 1 = Berlin

Comments?
*****
Logged
rpgfan3233
Ancient Guru
****
Posts: 617



« Reply #8 on: July 15, 2005, 09:13:53 PM »

Nice list. I agree with the terms. It makes it much easier. DST is hard to implement also because some time zones require it and some do not.
Logged

974277320612072617420666C61696C21 (Hexadecimal for those who don't know)
Moneo
Na_th_an
*****
Posts: 1971


« Reply #9 on: July 15, 2005, 10:14:19 PM »

Quote from: "rpgfan3233"
Nice list. I agree with the terms. It makes it much easier. DST is hard to implement also because some time zones require it and some do not.


Thanks, that makes two of us.
*****
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #10 on: July 16, 2005, 03:58:19 PM »

PLEASE NOTE:

1) Two minor modifications in SOLID CAPS have been edited to the original specifications of the challenge, for clarity.

2) Currently the requirements call for handling a date as input and  a calculated date as output. This implies a tedious date validation as well as rather complicated date arithmetic.

So, for those of you who prefer not dealing with dates, you may eliminate the date on input and output, and substitute on output a message indicating a day adjustment of 0, +1, or -1.

Example for using optional day adjustment:
If Input #1 has GMT-6 at 23:00,
and Input #2 wants results for GMT-4,
then the output time will be 01:00 with a day adjustment of +1.
Get it?
*****
Logged
Diroga
Been there, done that
*****
Posts: 1087


« Reply #11 on: July 17, 2005, 02:21:13 AM »

Quote from: "Moneo"
My son is in Japan this week participating in a Robocup (robots that play soccer) competition.


damn lucky punk
Logged
anarky
Been there, done that
*****
Posts: 1231


The Blobworld Comics King


« Reply #12 on: July 17, 2005, 05:07:38 AM »

Quote from: "Moneo"
Boy, do we have a can of worms regarding timezones.

I consulted my Encyclopaedia Britannica and World Book Encyclopedia and they both define 24 standard timezones.

There are numerous exceptions, but for this challenge, we will use the 24 timezones on the following list. I have included principal country/city names.

Also for this challenge, we will ignore the issue of daylight savings or summer time. It becomes almost impossible for our program to determine if the subject timezome uses daylight savings, when it starts and ends, and whether it advances one hour or two. Therefore, we will leave this daylight time adjustment up to the user of the program.

TIMEZONES:
GMT = London
GMT - 1 = Reykjavik
GMT - 2 = Greenland
GMT - 3 = Rio de Janeiro, Brazil
GMT - 4 = Santiago de Chile
GMT - 5 = New York
GMT - 6 = Chicago
GMT - 7 = Denver
GMT - 8 = Seattle
GMT - 9 = Alaska
GMT -10 = Honolulu
GMT -11 = Midway Island
GMT -12  (does not exist, see GMT +12)

continuing in a circle around the world............
GMT +12 = New Zealand
GMT +11 = Solomon Islands
GMT +10 = Sydney
GMT + 9  = Tokyo
GMT + 8  = Hong Kong, and China
GMT + 7  = Bangkok
GMT + 6 =  Omsk, Russia
GMT + 5 =  Karachi
GMT + 4 = Stalingrad
GMT + 3 = Moscow
GMT + 2 = Cairo
GMT + 1 = Berlin

Comments?
*****


It's easy to add the non-standard timezones. DST is harder, since that splits Australia up into a real mess. Darwin is GMT +9:30. So is Adelaide. Darwin and the NT do not have DST. Adelaide and SA do. Brisbane in QLD does not have DST, NSW, Vic and Tas have DST. WA does not. For ease of reading, I won't include the ACT, which is surrounded by NSW anyway.

During the winter time of the year, such as now, we have:

GMT +8:00 WA
GMT +9:30 SA, NT
GMT +10:00 QLD, NSW, ACT, VIC, TAS

During summer months:
GMT +8:00 WA
GMT +9:30 NT
GMT +10:00 QLD
GMT +10:30 SA
GMT +11:00 NSW, ACT, VIC TAS

Then what about the middle east? Last I heard, the whole area is one time zone, instead of 5 or 6.

The former USSR? 11 zones...

My opinion would be the following: include the GMT +/- x:30 non standard timezones. Don't include DST.

BTW, I live in SA. That makes me GMT +9:30 atm.

EDIT: According to http://wwp.greenwichmeantime.com/info/timezone.htm, Kiribati islands is over a day behind New Zealand. So Thursday in NZ is still Tuesday in Kiribati Is.

>anarky
Logged

Screwing with your reality since 1998.
Moneo
Na_th_an
*****
Posts: 1971


« Reply #13 on: July 17, 2005, 02:31:47 PM »

anarky,

Thanks for your exhaustive analysis of the timezone exceptions in Australia. As you can well imagine, no one is going to want to program these hairy exceptions into his program for Australia and any other non-standard timezone --- even if he happens to live there.
*****
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #14 on: July 19, 2005, 04:14:51 PM »

Hey guys,
Is anybody working on a solution for this challenge?

Heck, my family all say it's easy, that they can do it in their head. How many hours from New York (GMT-5) to Berlin (GMT+1)? That's easy: take the 5 and add the 1, so it's 6 hours away. And when you add the 6 hours to New York time and it goes passed midnight, then the Berlin date is +1 that of NY.

Yeah, yeah, yeah, but program the sucker to handle all 24x23 from/to timezone combinations!!!!!

I've got a program in the works, but I'm having trouble deciding whether to go clockwise around the world's timezomes, or counter-clockwise. The way the sample table is set up, it's going counter-clockwise.
Example: from New York (GMT-5)  to Tokyo (GMT-9) is 14 timezones clockwise and 10 counter-clockwise. If I go clockwise I add 14 hours to NY time, and for counter-clockwise I subtract 10 hours. Whick is easier or best?
And then what if the from and to are both GMT+ or both GMT- or from a GMT+ to a GMT-, then what's the general rule?

Have any of you guys thought about these issues?
*****
Logged
Pages: [1] 2 3 4
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!