I did that code :)
You have problems because the US changed the DST policy. Now it starts
at
SECOND SUNDAY of MARCH
and ends at FIRST SUNDAY of NOVEMBER.
So, USADLS now should be (2, 0, 3, 1, 0, 11);
I don't know if the other policies changed too.
This is the latest table:
OLD_USADST: new Dst(LAST, SUNDAY, OCTOBER, FIRST, SUNDAY, APRIL),
NEW_USADST: new Dst(FIRST, SUNDAY, NOVEMBER, SECOND, SUNDAY, MARCH),
EU_DST: new Dst(LAST, SUNDAY, OCTOBER, LAST, SUNDAY, MARCH),
CH_DST: new Dst(SECOND, SATURDAY, MARCH, SECOND, SATURDAY, OCTOBER),
OCBR_DST: new Dst(SECOND, SUNDAY, FEBRUARY, FIRST, SUNDAY, NOVEMBER),
NCBR_DST: new Dst(LAST, SUNDAY, FEBRUARY, FIRST, SUNDAY, NOVEMBER),
MV_DST: new Dst(SECOND, SUNDAY, MARCH, FIRST, SUNDAY, OCTOBER),
MA_DST: new Dst(LAST, SUNDAY, SEPTEMBER, LAST, SUNDAY, MARCH),
JD_DST: new Dst(LAST, FRIDAY, SEPTEMBER, LAST, THURSDAY, MARCH),
ME_DST: new Dst(LAST, SATURDAY, OCTOBER, LAST, SUNDAY, MARCH),
EG_DST: new Dst(LAST, THURSDAY, SEPTEMBER, LAST, THURSDAY, APRIL),
IS_DST: new Dst(THIRD, SUNDAY, SEPTEMBER, LAST, FRIDAY, MARCH),
NA_DST: new Dst(FIRST, SUNDAY, SEPTEMBER, FIRST, SUNDAY, APRIL),
AR_DST: new Dst(FIRST, SUNDAY, OCTOBER, FIRST, SUNDAY, APRIL),
IR_DST: new Dst(FOURTH, TUESDAY, SEPTEMBER, FIRST, SUNDAY, MARCH),
AU_DST: new Dst(LAST, SUNDAY, MARCH, LAST, SUNDAY, OCTOBER),
TA_DST: new Dst(LAST, SUNDAY, MARCH, FIRST, SUNDAY, OCTOBER),
NZ_DST: new Dst(THIRD, SUNDAY, MARCH, FIRST, SUNDAY, OCTOBER)
There are a couple of countries that do not have a "programatic" DST
but
moves from year to year.
Below is the XML I use to get the information I need:
Attributes:
n = name of the timezone
b = time offset (in minutes)
d = same, but in daylight
f and l = used to identify first and last nodes. Any year before f will
use the information in f for the calcs, any year after l will use the
information in l.
dst = the dst information from above.
shh, ehh: Start hour and End hour where the change occurs (so, it is
not
always at 00:00).
If a year does not has a DST information, it must has the information
regarding the start and end date (sd = start day, sm = start month, ed
=
end day, em = end month). If no information is provided (nor DST nor
Start/End dates), there are no DST for that specific year.
Also, remember that countries/timezones that have DST may or may not
apply
the policy (example: Check GreenLand in the TimeZone control pannel in
Windows, you have an option to adjust for DST or not).
Hope this helps....
<tzinfo>
<tz n="(GMT-12:00) International Date Line West" b="720"/>
<tz n="(GMT-11:00) Midway Island, Samoa" b="660"/>
<tz n="(GMT-10:00) Hawaii" b="600"/>
<tz n="(GMT-09:00) Alaska" b="540" d="480">
<y f="2006" dst="OLD_USADST" shh="2" ehh="2"/>
<y l="2007" dst="NEW_USADST" shh="2" ehh="2"/>
</tz>
<tz n="(GMT-08:00) Pacific Time (US & Canada)" b="480"
d="420">
<y f="2006" dst="OLD_USADST" shh="2" ehh="2"/>
<y l="2007" dst="NEW_USADST" shh="2" ehh="2"/>
</tz>
<tz n="(GMT-08:00) Tijuana, Baja California" b="480" d="420">
<y dst="OLD_USADST" shh="2" ehh="2"/>
</tz>
<tz n="(GMT-07:00) Arizona" b="420"/>
<tz n="(GMT-07:00) Chihuahua, La Paz, Mazatlan" b="420" d="360">
<y dst="OLD_USADST" shh="2" ehh="2"/>
</tz>
<tz n="(GMT-07:00) Mountain Time (US & Canada)" b="420"
d="360">
<y f="2006" dst="OLD_USADST" shh="2" ehh="2"/>
<y l="2007" dst="NEW_USADST" shh="2" ehh="2"/>
</tz>
<tz n="(GMT-06:00) Central America" b="360"/>
<tz n="(GMT-06:00) Central Time (US & Canada)" b="360"
d="300">
<y f="2006" dst="OLD_USADST" shh="2" ehh="2"/>
<y l="2007" dst="NEW_USADST" shh="2" ehh="2"/>
</tz>
<tz n="(GMT-06:00) Guadalajara, Mexico City, Monterrey" b="360"
d="300">
<y dst="OLD_USADST" shh="2" ehh="2"/>
</tz>
<tz n="(GMT-06:00) Saskatchewan" b="360"/>
<tz n="(GMT-05:00) Bogota, Lima, Quito, Rio Branco" b="300"/>
<tz n="(GMT-05:00) Eastern Time (US & Canada)" b="300"
d="240">
<y f="2006" dst="OLD_USADST" shh="2" ehh="2"/>
<y l="2007" dst="NEW_USADST" shh="2" ehh="2"/>
</tz>
<tz n="(GMT-05:00) Indiana (East)" b="300"/>
<tz n="(GMT-04:00) Atlantic Time (Canada)" b="240" d="180">
<y f="2006" dst="OLD_USADST" shh="2" ehh="2"/>
<y l="2007" dst="NEW_USADST" shh="2" ehh="2"/>
</tz>
<tz n="(GMT-04:00) Caracas, La Paz" b="240"/>
<tz n="(GMT-04:00) Manaus" b="240" d="180">
<y f="2006" dst="OCBR_DST" shh="2"/>
<y l="2007" dst="NCBR_DST"/>
</tz>
<tz n="(GMT-04:00) Santiago" b="240" d="180">
<y dst="CH_DST" shh="23" smm="59" sss="59" ehh="23"
emm="59" ess="59"/>
</tz>
<tz n="(GMT-03:30) Newfoundland" b="210" d="150">
<y f="2006" dst="OLD_USADST" smm="1" emm="1"/>
<y l="2007" dst="NEW_USADST" smm="1" emm="1"/>
</tz>
<tz n="(GMT-03:00) Brasilia" b="180" d="120">
<y f="2006" dst="OCBR_DST" shh="2"/>
<y l="2007" dst="NCBR_DST"/>
</tz>
<tz n="(GMT-03:00) Buenos Aires, Georgetown" b="180"/>
<tz n="(GMT-03:00) Greenland" b="180" d="120">
<y dst="OLD_USADST" shh="2" ehh="2"/>
</tz>
<tz n="(GMT-03:00) Montevideo" b="180" d="120">
<y dst="MV_DST" shh="2" ehh="2"/>
</tz>
<tz n="(GMT-02:00) Mid-Atlantic" b="120" d="60">
<y dst="MA_DST" shh="2" ehh="2"/>
</tz>
<tz n="(GMT-01:00) Azores" b="60" d="0">
<y dst="EU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT-01:00) Cape Verde Is." b="60"/>
<tz n="(GMT) Casablanca, Monrovia, Reykjavik" b="0"/>
<tz n="(GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon,
London"
b="0" d="-60">
<y dst="EU_DST" shh="2" ehh="1"/>
</tz>
<tz n="(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm,
Vienna"
b="-60" d="-120">
<y dst="EU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana,
Prague"
b="-60" d="-120">
<y dst="EU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+01:00) Brussels, Copenhagen, Madrid, Paris" b="-60"
d="-120">
<y dst="EU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+01:00) Sarajevo, Skopje, Warsaw, Zagreb" b="-60"
d="-120">
<y dst="EU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+01:00) West Central Africa" b="-60"/>
<tz n="(GMT+02:00) Amman" b="-120" d="-180">
<y dst="JD_DST" shh="1"/>
</tz>
<tz n="(GMT+02:00) Athens, Bucharest, Istanbul" b="-120"
d="-180">
<y dst="EU_DST" shh="4" ehh="3"/>
</tz>
<tz n="(GMT+02:00) Beirut" b="-120" d="-180">
<y dst="ME_DST" shh="23" smm="59" sss="59"/>
</tz>
<tz n="(GMT+02:00) Cairo" b="-120" d="-180">
<y dst="EG_DST" shh="23" smm="59" sss="59" ehh="23"
emm="59" ess="59"/>
</tz>
<tz n="(GMT+02:00) Harare, Pretoria" b="-120"/>
<tz n="(GMT+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn,
Vilnius"
b="-120" d="-180">
<y dst="EU_DST" shh="4" ehh="3"/>
</tz>
<tz n="(GMT+02:00) Jerusalem" b="-120" d="-180">
<y f="2003" dst="IS_DST" shh="2" ehh="2"/>
<y n="2004"/>
<y n="2005" sd="9" sm="9" ed="1" em="3" shh="2"
ehh="2"/>
<y n="2006" sd="1" sm="9" ed="31" em="2" shh="2"
ehh="2"/>
<y n="2007" sd="16" sm="8" ed="30" em="2" shh="2"
ehh="2"/>
<y n="2008" sd="5" sm="9" ed="28" em="2" shh="2"
ehh="2"/>
<y n="2009" sd="27" sm="8" ed="27" em="2" shh="2"
ehh="2"/>
<y n="2010" sd="12" sm="8" ed="26" em="2" shh="2"
ehh="2"/>
<y n="2011" sd="2" sm="9" ed="1" em="3" shh="2"
ehh="2"/>
<y n="2012" sd="23" sm="8" ed="30" em="2" shh="2"
ehh="2"/>
<y n="2013" sd="8" sm="8" ed="29" em="2" shh="2"
ehh="2"/>
<y n="2014" sd="28" sm="8" ed="28" em="2" shh="2"
ehh="2"/>
<y n="2015" sd="20" sm="8" ed="27" em="2" shh="2"
ehh="2"/>
<y n="2016" sd="9" sm="9" ed="1" em="3" shh="2"
ehh="2"/>
<y n="2017" sd="24" sm="8" ed="31" em="2" shh="2"
ehh="2"/>
<y n="2018" sd="16" sm="8" ed="30" em="2" shh="2"
ehh="2"/>
<y n="2019" sd="6" sm="9" ed="29" em="2" shh="2"
ehh="2"/>
<y n="2020" sd="27" sm="8" ed="27" em="2" shh="2"
ehh="2"/>
<y n="2021" sd="12" sm="8" ed="26" em="2" shh="2"
ehh="2"/>
<y l="2022" sd="2" sm="9" ed="1" em="3" shh="2"
ehh="2"/>
</tz>
<tz n="(GMT+02:00) Minsk" b="-120" d="-180">
<y dst="EU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+02:00) Windhoek" b="-120" d="-60">
<y dst="NA_DST" shh="2" ehh="2"/>
</tz>
<tz n="(GMT+03:00) Baghdad" b="-180" d="-240">
<y dst="AR_DST" shh="4" ehh="3"/>
</tz>
<tz n="(GMT+03:00) Kuwait, Riyadh" b="-180"/>
<tz n="(GMT+03:00) Moscow, St. Petersburg, Volgograd" b="-180"
d="-240">
<y dst="EU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+03:00) Nairobi" b="-180"/>
<tz n="(GMT+03:00) Tbilisi" b="-180"/>
<tz n="(GMT+03:30) Tehran" b="-210" d="-270">
<y n="2005" dst="IR_DST" shh="2" ehh="2"/>
</tz>
<tz n="(GMT+04:00) Abu Dhabi, Muscat" b="-240"/>
<tz n="(GMT+04:00) Baku" b="-240" d="-300">
<y dst="EU_DST" shh="5" ehh="4"/>
</tz>
<tz n="(GMT+04:00) Yerevan" b="-240" d="-300">
<y dst="EU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+04:30) Kabul" b="-270"/>
<tz n="(GMT+05:00) Ekaterinburg" b="-300" d="-360">
<y dst="EU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+05:00) Islamabad, Karachi, Tashkent" b="-300"/>
<tz n="(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi"
b="-330"/>
<tz n="(GMT+05:30) Sri Jayawardenepura" b="-330"/>
<tz n="(GMT+05:45) Kathmandu" b="-345"/>
<tz n="(GMT+06:00) Almaty, Novosibirsk" b="-360" d="-420">
<y dst="EU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+06:00) Astana, Dhaka" b="-360"/>
<tz n="(GMT+06:30) Yangon (Rangoon)" b="-390"/>
<tz n="(GMT+07:00) Bangkok, Hanoi, Jakarta" b="-420"/>
<tz n="(GMT+07:00) Krasnoyarsk" b="-420" d="-480">
<y dst="EU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi"
b="-480"/>
<tz n="(GMT+08:00) Irkutsk, Ulaan Bataar" b="-480" d="-540">
<y dst="EU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+08:00) Kuala Lumpur, Singapore" b="-480"/>
<tz n="(GMT+08:00) Perth" b="-480" d="-540">
<y f="2004" dst="AU_DST" shh="3" ehh="2"/>
<y n="2005"/>
<y n="2006" sd="1" sm="0" ed="1" em="11" ehh="2"/>
<y l="2007" dst="AU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+08:00) Taipei" b="-480"/>
<tz n="(GMT+09:00) Osaka, Sapporo, Tokyo" b="-540"/>
<tz n="(GMT+09:00) Seoul" b="-540"/>
<tz n="(GMT+09:00) Yakutsk" b="-540" d="-600">
<y dst="EU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+09:30) Adelaide" b="-570" d="-630">
<y dst="AU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+09:30) Darwin" b="-570"/>
<tz n="(GMT+10:00) Brisbane" b="-600"/>
<tz n="(GMT+10:00) Canberra, Melbourne, Sydney" b="-600"
d="-660">
<y dst="AU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+10:00) Guam, Port Moresby" b="-600"/>
<tz n="(GMT+10:00) Hobart" b="-600" d="-660">
<y dst="TA_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+10:00) Vladivostok" b="-600" d="-660">
<y dst="EU_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+11:00) Magadan, Solomon Is., New Caledonia"
b="-660"/>
<tz n="(GMT+12:00) Auckland, Wellington" b="-720" d="-780">
<y dst="NZ_DST" shh="3" ehh="2"/>
</tz>
<tz n="(GMT+12:00) Fiji, Kamchatka, Marshall Is." b="-720"/>
<tz n="(GMT+13:00) Nuku'alofa" b="-780"/>
</tzinfo>
On Wed, 26 Mar 2008 19:25:47 -0300, Corban Baxter <[EMAIL PROTECTED]>
wrote:
> Hey all,
> because of the daylight savings time going on across the world I was
> having trouble with the world clocks I setup for a client. I tried to
> implement the code below but was un succesful to do it correctly
> apparently. Does anyone have any working examples of this. And if so
> do you mind sharing? Thanks ALL!!
>
>
>
> Code via: Keith Reinsfield (I think* sorry...)
> dstPolicies = {
> 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
> */
>
> function calcStartEnd(y:Number, m:Number, n:Number, w:Number):Number
{
> 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:Number = 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.
> */
>
> function getDayOfWeek(y:Number, m:Number, d:Number):Number {
> var a:Number = Number((14-m)/12);
> y -= a;
> m += 12*a-2;
> var r:Number =
> (d+y+Number(y/4)-Number(y/100)+Number(y/400)+int((31*m)/12))%7;
> if (r<0) {
> return 7+r;
>
> } else {
> return r;
> }
> }
>
--
Marcelo Volmaro
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders