Intel's Ronler Acres Plant

Silicon Forest
If the type is too small, Ctrl+ is your friend

Tuesday, October 21, 2003

Calculating the timezone offset from the Longitude

Here is an example of the kind of math I had to deal with today. Thought R & K might be amused. Or not. OK, so maybe my job is a little oddball.

Calculating the timezone offset from the Longitude that we get from the GPS.

(GPS - Global Positioning System). We have a GPS module we use in our radio to get the current time. But the current time is GMT (Greenwich Mean Time), which doesn't mean much to someone in Timbuktu. We also can get our longitude from the GPS. So from the Longitude and the GMT, we can calculate what timezone we are in, and with that we can figure out what the local time is.

Longitude is given in milli-arc-seconds (mas).
There are 3,600,000 mas in one degree (60 minutes * 60 seconds * 1000)
There are 15 degrees per time zone (360 degrees divided by 24 hours per day).

Divide Longitude by 3,600,000 gives longitude in degrees.
Divide result by 15 gives timezone, which is the same as the hourly difference.
Multiply result by 3600 to get timezone in seconds
Multiply result by -1 to get the direction to agree with Microsoft's timezone variable.

Combined, we have:

Longitude * 3,600 * -1
----------------------------
15 * 3,600,000

Reduced we get:

Timezone = Longitude / -15,000

No comments: