nice move john much appreciated!

On 9/6/07, John VanHorn <[EMAIL PROTECTED]> wrote:
>
> yes, the flash Date object provides all the necessary properties to
> calculate the time for different time zones, but it still wont be accurate
> if the user's clock is off.
>
> for more accuracy, youll need to have the time from the server. this
> should
> be simple to do with any server side language. in php, you can use the
> date('U') function or the time() function, which will both give you the
> Unix
> timestamp - the number of seconds that have passed since 12am January 1,
> 1970. you can pass that into your swf using flashvars. you can then create
> a
> Date object based off of that value. just note that (in php, at least) the
> value is seconds, and the flash Date object uses milliseconds. oh, and
> load
> time of your swf may cause that to be off a little. if thats a problem,
> you
> could store it in a javascript Date object, and then grab the value when
> youre ready for it.
>
>
> On 9/6/07, Marcelo Volmaro <[EMAIL PROTECTED]> wrote:
> >
> > I took that data from various sources. I'm using that for my own clock
> > too, and also have a function that, taking a "position" (first, second,
> > third, etc), a month and "day" can calculate the real date when a DST
> > occurs (for example, you feed "first Friday of may" or "last Monday of
> > December" and it returns the correct date for a specific year).
> >
> > I have a list of DST/Timezones per location, but did not converted to AS
> > (I have some XML files). The problem is that the list is a big one,
> > because the list is compromised of:
> > a) Countries
> > b) Regions
> > c) States
> > d) Cities.
> >
> > Usually, you can trim down the list a lot, since almost all cities in a
> > country have the same TZ/DST, but that's not the case for the US. In
> fact,
> > you have some cities on the same state that have different TZ.
> >
> > You can get the complete list from:
> >
> > http://www.isi.edu/~pan/SWBP/time-zone-note/time-zone-note.html
> >
> > The problem with that list is that the dates specified for the start/end
> > of DST is that are tied to a specific year and usually you need to wait
> > until someone updates that list... so I coded the following list that
> has
> > all the info necessary to do the calcs:
> >
> >                 private static const dstPolicies:Object = {
> >                         USADLS:new DstPolicy(1,0,4, -1,0,10),
> >                         EUDLS:new DstPolicy(-1,0,3, -1,0,10),
> >                         AU2003DLS:new DstPolicy(-1,0,10, -1,0,3),
> >                         AUTDLS:new DstPolicy(1,1,10, -1,0,3),
> >                         RUDLS:new DstPolicy(-1,0,3, -1,0,10),
> >                         EGDLS:new DstPolicy(-1,5,4, -1,4,9),
> >                         IRDLS:new DstPolicy(-1,6,3, -1,1,9),
> >                         IQDLS:new DstPolicy(255, 1,4, 255, 1,10),
> >                         ILDLS:new DstPolicy(-1,4,3, 1,4,10),
> >                         JODLS:new DstPolicy(-1,3,3, -1,4,10),
> >                         NADLS:new DstPolicy(1,0,9, 1,0,4),
> >                         PKDLS:new DstPolicy(1,6,4, 1,6,10),
> >                         SYDLS:new DstPolicy(255,30,3, 255,21,9),
> >                         CLDLS:new DstPolicy(2,0,10, 2,0,3),
> >                         CLEDLS:new DstPolicy(2,5,10, 2,6,3),
> >                         NZDLS:new DstPolicy(1,0,10, 3,0,3),
> >                         PYDLS:new DstPolicy(1,0,9, 1,0,4),
> >                         FKDLS:new DstPolicy(1,0,9, -1,0,4)
> >                 };
> >
> > Where the first number is the position (1: first, -1:last, 255: straight
> > date), the second and the third are the day/month.
> > If the position is 255, the date is a straight day/month date, so for
> > example for IRAQ the start date is April 1.
> >
> > The formulas for the calcs are:
> >
> >                 /**
> >                  * @param y:int Year
> >                  * @param m:int Month (0 - 11)
> >                  * @param n:int Day of the week (0 for a Sunday, 1 for a
> > Monday, 2 for a
> > Tuesday, etc)
> >                  * @param w:int Occurence (1:first, 2:second, 3:third,
> > 4:fourth, -1:last)
> >                  * @return real day of the month where the DST
> starts/ends
> >                  *
> >                  * first friday = w:1, n:5
> >                  * third monday = w:3, n:1
> >                  * last monday = w:-1, n:1
> >                  */
> >
> >                 private static function calcStartEnd(y:int, m:int,
> n:int,
> > w:int):int{
> >                         if (w < 0){
> >                                 var nd:Number = (new Date(y, m,
> > 0)).getDate();
> >                                 var diff:Number = (getDayOfWeek(y, m+1,
> > nd) - n) % 7;
> >                                 if (diff < 0) diff += 7;
> >                                 return nd-diff;
> >                         }
> >
> >                         var nq:int = 7 * w - 6 + (n - getDayOfWeek(y,
> m+1,
> > 1)) % 7;
> >                         if (nq < 1) nq += 7;
> >
> >                         return nq;
> >                 }
> >
> >                 /**
> >                  * @param y:int Year
> >                  * @param m:int Month (1 - 12)
> >                  * @param d:int Day (1 - 31)
> >                  * @return 0 for a Sunday, 1 for a Monday, 2 for a
> > Tuesday, etc.
> >                  */
> >
> >                 private static function getDayOfWeek(y:int, m:int,
> > d:int):int{
> >                         var a:int = int((14 - m) / 12);
> >                         y -= a;
> >                         m += 12 * a - 2;
> >                         var r:int =  (d + y + int(y/4) - int(y/100) +
> > int(y/400)
> > + int((31*m)/12))%7;
> >                         if (r < 0) {
> >                                 return 7+r;
> >
> >                         } else {
> >                                 return r;
> >                         }
> >                 }
> >
> >
> >
> > Hope it helps...
> >
> >
> > On Thu, 06 Sep 2007 13:03:13 -0300, Keith Reinfeld
> > <[EMAIL PROTECTED]> wrote:
> >
> > > Hi Corban,
> > >
> > > Yes, I've been working on mine. I really want to thank Marcelo for the
> > > timezones array. Very helpful! Where did that come from?
> > >
> > > I have worked out a mechanism for applying Daylight Savings Time
> rules.
> > > Now
> > > all I need is the data, by location, to pass in.
> > >
> > > Note to Jim Berkey: First, thank you for the link. Nice touch with the
> > > iconic location graphics. Second, I'm getting a 404 for the worldclock
> > > source file. Just FYI.
> > >
> > > Regards,
> > >
> > > -Keith
> > > http://keithreinfeld.home.comcast.net
> > >
> > >
> > > _______________________________________________
> > > Flashcoders@chattyfig.figleaf.com
> > > To change your subscription options or search the archive:
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > > Brought to you by Fig Leaf Software
> > > Premier Authorized Adobe Consulting and Training
> > > http://www.figleaf.com
> > > http://training.figleaf.com
> >
> >
> >
> > --
> > Marcelo Volmaro
> > _______________________________________________
> > Flashcoders@chattyfig.figleaf.com
> > To change your subscription options or search the archive:
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.com
> >
>
>
>
> --
> John Van Horn
> [EMAIL PROTECTED]
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>



-- 
Corban Baxter
http://www.projectx4.com
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to