-
Animal Flasher
different timezones for radio schedule......
hi, I'm trying to write some code to display a radio schedule.
I'm playing around with getHour
Code:
hour = now.getHour();
if hour>6 && hour<9
program="Breakfast Show";
else if hour>9 && hour<12
program="Just After Breakfast Show";
etc......
where 'program' is a line of dynamic text..... but I'm not really getting any where
I've also realised that getHour refers to the system clock and so would only be relevant in the same country where the Radio show is being heard.... is it possible to calculate all times based upon GMT..????
If anyone's got any ideas on any of this I'd be very grateful..... (pulling hair out time..... again...)
-
Senior Member
All the get/set methods for the Date object have UTC (Universal Time Code) equivalents.
So you can create a UTC date (for your radio schedule) using setUTCHours(), and then use the non-UTC method getHours() to retrieve the local version of that time to display to the user.
- Jim
-
Animal Flasher
eek...
Not at all sure as to where you're coming from with that one... I understand that I have to set the timezone and then offset it in either direction... but I have no idea as where to start...
I'm still having trouble getting my 'local' time code working
Code:
myDate = new Date( year, month, date, hour, min, sec, ms );
hours = mydate.getHours();
if (int (hours)>6 && (hours)<9) {
program = "Breakfast Show";
}
else if (int (hours)>9 && (hours)<12) {
program = "Just After Breakfast Show";
}
else {
program = "PROGRAM SCHEDULE";
}
which is butchered code from a clock that I did a very long time ago....
-
Senior Member
If your work in UTC time, then you don't have to figure out the user's timezone. It gets taken care of for you.
First off, you need to figure what UTC hours your breakfast show actually runs in (this will be the same all over the world). More on that step below.
Once you've figured out your UTC schedule, things are simpler.
In the example script you showed above, use getUTCHours() instead of getHours().
Let's say you figure out that your breakfast show runs from 12-15:00 in UTC hours.
myDate = new Date( year, month, date, hour, min, sec, ms );
// or just myDate = new Date() if you want the current time.
hours = mydate.getUTCHours();
if (int (hours)>=12 && (hours)<=15) {
program = "Breakfast Show";
}
// etc. etc. etc.
So the code is basically the same as what you would use locally, but you use getUTCHours(),
and you have to figure out your UTC schedule.
To figure out your UTC schedule, make a test movie that does something like this:
dt = new Date();
trace("Current hour " + dt.getHours());
trace("UTC hour " + dt.getUTCHours());
offset = dt.getUTCHours() - dt.getHours();
trace("UTC Offset = " + offset);
From this you can figure out the difference between UTC and local time,and then just add that offset to all the hours in your schedule.
For example, I live in Los Angeles, and the above script produces the following:
Current hour 15
UTC hour 22
UTC Offset = 7
So if my breakfast show ran from 9-12 locally, I would program my breakfast show to run from 16-19 based on getUTCHours().
Hope this helps.
- Jim
Last edited by jbum; 09-30-2004 at 06:42 PM.
-
Animal Flasher
Thanks Jim, I'll have a ponder over all this - I've got the schedule, so I know my times, so I guess it's just a case of playing around with this code til I can get something to work.
Nice one. Thanks for your help
Rob
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|