Re: [Flashcoders] coding a world clock
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
RE: [Flashcoders] coding a world clock
Thanks again, Marcelo! The DST Policies scheme works wonderfully. Brilliant! I'm sure I read somewhere that you need to delete the Date object once you are done with it. Otherwise it will persist in memory. Have you noticed any memory leaks associated with these calcs? 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
Re: [Flashcoders] coding a world clock
hey keith or any of you guys have you had a chance to look any further into this. I have put it to the side since the time i posted but I am going to try and get back at it very quickly. On 9/3/07, Marcelo Volmaro [EMAIL PROTECTED] wrote: Something like this? private static var timeZones:Array = [ [-1, Azores,Brazil Atlantic Islands,Cape Verde,Greenland Scoresbysun,Guinea Bissau], [-2, Antarctica], [-3, Argentina,Brazil East, French Guiana, Greenland, Guyana,St Pierre Miquelon,Suriname,Uruguay], [-3.5, Canada Newfoundland], [-4, AST: Atlantic Standard,Anguilla, Antigua, Argentina western prov,Aruba,Barbados,Bermuda,Bolivia,Bonaire,Brazil Acre,Brazil West,British Virgin Islands,Canada Atlantic,Chile,Curacao,Dominica,Dominican Republic,Falkland Islands,Greenland Thule,Grenada,Grenadines,Guadeloupe,Leeward Islands,Martinique,Netherlands Antilles,Nevis Montserrat,Paraguay,Puerto Rico,Saba,St Christopher,St Croix,St John,St Kitts Nevis,St Lucia,St Maarten,St Thomas,St Vincent,Trinidad and Tobago,Venezuela,Virgin Islands,Windward Islands], [-5, EST: Eastern Standard,Bahamas,Canada Eastern,Cayman Islands,Colombia,Cuba,Ecuador,Galapagos Islands,Haiti,Jamaica,Panama,Peru,Turks and Caicos Islands,USA Eastern,USA Indiana East], [-6, CST: Central Standard,Belize, Canada Central,Costa Rica,Easter Island,El Salvador,Guatemala,Honduras,Mexico,Nicaragua,USA Central], [-7, MST: Mountain Standard,Canada Mountain,Mexico Nayarit,Mexico Sinaloa,Mexico Sonora,USA Arizona,USA Mountain], [-8, PST: Pacific Standard,Canada Yukon Pacific,Mexico Baja Calif Norte,USA Pacific], [-9, Gambier Island,USA Alaska], [-9, Marquesas Islands], [-10, Christmas Islands,Cook Islands,French Polynesia,Johnston Island,Society Island,Tahiti,Tuamotu Island,Tubuai Island,USA Aleutian,USA Hawaii], [-11, NT: Nome,American Samoa,Canton Enderbury Islands,Midway Island,Niue Island,Samoa], [-12, IDLW: International Date Line West], [0, Ascension,Burkina Faso,Canary Islands,Channel Islands,Cote d'Ivoire,England,Faroe Island,Gambia,Ghana,Guinea,Iceland,Ireland Republic of,Liberia,Madeira,Mali,Mauritania,Morocco,Northern Ireland,Principe Island,Sao Tome e Principe,Scotland,Senegal,Sierra Leone,St Helena,Togo,United Kingdom,Wales], [1.00, CET Central European, Albania,Algeria,Andorra,Angola,Austria,Balearic Islands,Belgium,Benin,Bosnia Hercegovina,Cameroon,Central African Rep,Chad,Congo,Czech Republic,Dahomey,Denmark,Equatorial Guinea,France,Gabon,Germany,Gibraltar,Hungary,Italy,Luxembourg,Macedonia,Mallorca Islands,Malta,Melilla,Monaco,Namibia,Netherlands,Niger,Nigeria,Norway,Poland,Portugal,San Marino,Slovakia,Slovenia,Spain,Sweden,Switzerland,Tunisia,Vatican City,Yugoslavia,Zaire Kinshasa Mbandaka,Croatia], [2.00, EET Eastern European,Belarus,Botswana,Bulgaria,Burundi,Cyprus,Egypt,Estonia,Finland,Greece,Israel,Jordan,Latvia,Lebanon,Lesotho,Libya,Lithuania,Malawi,Moldova,Moldovian Rep Pridnestrovye,Mozambique,Romania,Russian Federation zone one,Rwanda,South Africa,Sudan,Swaziland,Syria,Turkey,Ukraine,Zaire Haut Zaire,Zaire Kasai,Zaire Kivu,Zaire Shaba,Zambia,Zimbabwe], [3.00, Azerbaijan,Bahrain,Djibouti,Eritrea,Ethiopia,Iraq,Kenya,Kuwait,Madagascar,Mayotte,Qatar,Russian Federation zone two,Saudi Arabia,Somalia,Tanzania,Uganda,Yemen], [3.50, Iran], [4.00, Armenia,Georgia,Mauritius,Oman,Reunion,Russian Federation zone three,Seychelles,United Arab Emirates], [4.50, Afghanistan], [5.00, Kyrgyzstan,Maldives,Pakistan,Russian Federation zone four,Turkmenistan,Uzbekistan], [5.50, India,Sri Lanka], [5.75, Nepal], [6.00, Bangladesh,Bhutan,Kazakhstan,Russian Federation zone five,Tajikistan], [6.50, Myanmar], [7.00, Cambodia,Indonesia West,Laos,Russian Federation zone six,Thailand,Vietnam], [8.00, Australia Western,Brunei,China People's Rep,Hong Kong,Indonesia Central,Malaysia,Mongolia,Philippines,Russian Federation zone seven,Singapore,Taiwan], [9.00, YST: Yukon Standard,Indonesia East,Japan,Korea Dem Republic of,Korea Republic of,Palau,Russian Federation zone eight], [9.50, Australia Northern Territory,Australia South], [10.00, AHST: Alaska-Hawaii Standard,CAT: Central Alaska,HST: Hawaii Standard,Australia New South Wales,Australia Queensland,Australia Tasmania,Australia Victoria,Australian Capital Territory,Guam,Mariana Island,Northern Mariana Islands,Papua New Guinea,Russian Federation zone nine], [10.50, Australia Lord Howe Island],
Re: [Flashcoders] coding a world clock
I did something for a client that may be helpful - It's in AS2 - easy to modify, add to, etc.: http://jimbo.us/lab/worldClock.html Jimbo http://jimbo.us - Original Message - From: Corban Baxter [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Thursday, September 06, 2007 10:17 AM Subject: Re: [Flashcoders] coding a world clock hey keith or any of you guys have you had a chance to look any further into this. I have put it to the side since the time i posted but I am going to try and get back at it very quickly. On 9/3/07, Marcelo Volmaro [EMAIL PROTECTED] wrote: Something like this? private static var timeZones:Array = [ [-1, Azores,Brazil Atlantic Islands,Cape Verde,Greenland Scoresbysun,Guinea Bissau], [-2, Antarctica], [-3, Argentina,Brazil East, French Guiana, Greenland, Guyana,St Pierre Miquelon,Suriname,Uruguay], [-3.5, Canada Newfoundland], [-4, AST: Atlantic Standard,Anguilla, Antigua, Argentina western prov,Aruba,Barbados,Bermuda,Bolivia,Bonaire,Brazil Acre,Brazil West,British Virgin Islands,Canada Atlantic,Chile,Curacao,Dominica,Dominican Republic,Falkland Islands,Greenland Thule,Grenada,Grenadines,Guadeloupe,Leeward Islands,Martinique,Netherlands Antilles,Nevis Montserrat,Paraguay,Puerto Rico,Saba,St Christopher,St Croix,St John,St Kitts Nevis,St Lucia,St Maarten,St Thomas,St Vincent,Trinidad and Tobago,Venezuela,Virgin Islands,Windward Islands], [-5, EST: Eastern Standard,Bahamas,Canada Eastern,Cayman Islands,Colombia,Cuba,Ecuador,Galapagos Islands,Haiti,Jamaica,Panama,Peru,Turks and Caicos Islands,USA Eastern,USA Indiana East], [-6, CST: Central Standard,Belize, Canada Central,Costa Rica,Easter Island,El Salvador,Guatemala,Honduras,Mexico,Nicaragua,USA Central], [-7, MST: Mountain Standard,Canada Mountain,Mexico Nayarit,Mexico Sinaloa,Mexico Sonora,USA Arizona,USA Mountain], [-8, PST: Pacific Standard,Canada Yukon Pacific,Mexico Baja Calif Norte,USA Pacific], [-9, Gambier Island,USA Alaska], [-9, Marquesas Islands], [-10, Christmas Islands,Cook Islands,French Polynesia,Johnston Island,Society Island,Tahiti,Tuamotu Island,Tubuai Island,USA Aleutian,USA Hawaii], [-11, NT: Nome,American Samoa,Canton Enderbury Islands,Midway Island,Niue Island,Samoa], [-12, IDLW: International Date Line West], [0, Ascension,Burkina Faso,Canary Islands,Channel Islands,Cote d'Ivoire,England,Faroe Island,Gambia,Ghana,Guinea,Iceland,Ireland Republic of,Liberia,Madeira,Mali,Mauritania,Morocco,Northern Ireland,Principe Island,Sao Tome e Principe,Scotland,Senegal,Sierra Leone,St Helena,Togo,United Kingdom,Wales], [1.00, CET Central European, Albania,Algeria,Andorra,Angola,Austria,Balearic Islands,Belgium,Benin,Bosnia Hercegovina,Cameroon,Central African Rep,Chad,Congo,Czech Republic,Dahomey,Denmark,Equatorial Guinea,France,Gabon,Germany,Gibraltar,Hungary,Italy,Luxembourg,Macedonia,Mallorca Islands,Malta,Melilla,Monaco,Namibia,Netherlands,Niger,Nigeria,Norway,Poland,Portugal,San Marino,Slovakia,Slovenia,Spain,Sweden,Switzerland,Tunisia,Vatican City,Yugoslavia,Zaire Kinshasa Mbandaka,Croatia], [2.00, EET Eastern European,Belarus,Botswana,Bulgaria,Burundi,Cyprus,Egypt,Estonia,Finland,Greece,Israel,Jordan,Latvia,Lebanon,Lesotho,Libya,Lithuania,Malawi,Moldova,Moldovian Rep Pridnestrovye,Mozambique,Romania,Russian Federation zone one,Rwanda,South Africa,Sudan,Swaziland,Syria,Turkey,Ukraine,Zaire Haut Zaire,Zaire Kasai,Zaire Kivu,Zaire Shaba,Zambia,Zimbabwe], [3.00, Azerbaijan,Bahrain,Djibouti,Eritrea,Ethiopia,Iraq,Kenya,Kuwait,Madagascar,Mayotte,Qatar,Russian Federation zone two,Saudi Arabia,Somalia,Tanzania,Uganda,Yemen], [3.50, Iran], [4.00, Armenia,Georgia,Mauritius,Oman,Reunion,Russian Federation zone three,Seychelles,United Arab Emirates], [4.50, Afghanistan], [5.00, Kyrgyzstan,Maldives,Pakistan,Russian Federation zone four,Turkmenistan,Uzbekistan], [5.50, India,Sri Lanka], [5.75, Nepal], [6.00, Bangladesh,Bhutan,Kazakhstan,Russian Federation zone five,Tajikistan], [6.50, Myanmar], [7.00, Cambodia,Indonesia West,Laos,Russian Federation zone six,Thailand,Vietnam], [8.00, Australia Western,Brunei,China People's Rep,Hong Kong,Indonesia Central,Malaysia,Mongolia,Philippines,Russian Federation zone seven,Singapore,Taiwan], [9.00, YST: Yukon Standard,Indonesia East,Japan,Korea Dem Republic of,Korea Republic of,Palau,Russian Federation zone eight], [9.50, Australia Northern Territory,Australia South], [10.00, AHST: Alaska-Hawaii Standard,CAT: Central Alaska,HST: Hawaii Standard,Australia
RE: [Flashcoders] coding a world clock
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
Re: [Flashcoders] coding a world clock
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 Sorry blush had to uncloak it in Dreamweaver before I uploaded. Should be there now. ___ 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
RE: [Flashcoders] coding a world clock
Hi Jim, Thanks again! Is it just me (Flash 8) or does anybody else get the 'Unexpected File Format' error? What version of Flash was your worldclock.fla created in? 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
Re: [Flashcoders] coding a world clock
It's in CS3 now. I'll save a Flash 8 version and put it up. Check in 10 minutes. Sorry. Also, code is in the separate mc's for each clock, not on the first frame, it's an old piece I haven't updated. Jimbo http://jimbo.us - Original Message - From: Keith Reinfeld [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Thursday, September 06, 2007 12:36 PM Subject: RE: [Flashcoders] coding a world clock Hi Jim, Thanks again! Is it just me (Flash 8) or does anybody else get the 'Unexpected File Format' error? What version of Flash was your worldclock.fla created in? 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 ___ 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
Re: [Flashcoders] coding a world clock
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
Re: [Flashcoders] coding a world clock
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. */
RE: [Flashcoders] coding a world clock
Hi, This thread inspired me to prototype my own world clock. And, yes the Date object does provide the means to convert local time to remote time IF you have the remote location's GMT offset value to plug in. I think this is the data Corban was asking after. http://wwp.greenwichmeantime.com/ and Wikipedia maybe good general information sources, but I haven't been able to find a nice tidy list of locations and their GMT offsets that I can effortlessly implement in Flash. 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
Re: [Flashcoders] coding a world clock
Something like this? private static var timeZones:Array = [ [-1, Azores,Brazil Atlantic Islands,Cape Verde,Greenland Scoresbysun,Guinea Bissau], [-2, Antarctica], [-3, Argentina,Brazil East, French Guiana, Greenland, Guyana,St Pierre Miquelon,Suriname,Uruguay], [-3.5, Canada Newfoundland], [-4, AST: Atlantic Standard,Anguilla, Antigua, Argentina western prov,Aruba,Barbados,Bermuda,Bolivia,Bonaire,Brazil Acre,Brazil West,British Virgin Islands,Canada Atlantic,Chile,Curacao,Dominica,Dominican Republic,Falkland Islands,Greenland Thule,Grenada,Grenadines,Guadeloupe,Leeward Islands,Martinique,Netherlands Antilles,Nevis Montserrat,Paraguay,Puerto Rico,Saba,St Christopher,St Croix,St John,St Kitts Nevis,St Lucia,St Maarten,St Thomas,St Vincent,Trinidad and Tobago,Venezuela,Virgin Islands,Windward Islands], [-5, EST: Eastern Standard,Bahamas,Canada Eastern,Cayman Islands,Colombia,Cuba,Ecuador,Galapagos Islands,Haiti,Jamaica,Panama,Peru,Turks and Caicos Islands,USA Eastern,USA Indiana East], [-6, CST: Central Standard,Belize, Canada Central,Costa Rica,Easter Island,El Salvador,Guatemala,Honduras,Mexico,Nicaragua,USA Central], [-7, MST: Mountain Standard,Canada Mountain,Mexico Nayarit,Mexico Sinaloa,Mexico Sonora,USA Arizona,USA Mountain], [-8, PST: Pacific Standard,Canada Yukon Pacific,Mexico Baja Calif Norte,USA Pacific], [-9, Gambier Island,USA Alaska], [-9, Marquesas Islands], [-10, Christmas Islands,Cook Islands,French Polynesia,Johnston Island,Society Island,Tahiti,Tuamotu Island,Tubuai Island,USA Aleutian,USA Hawaii], [-11, NT: Nome,American Samoa,Canton Enderbury Islands,Midway Island,Niue Island,Samoa], [-12, IDLW: International Date Line West], [0, Ascension,Burkina Faso,Canary Islands,Channel Islands,Cote d'Ivoire,England,Faroe Island,Gambia,Ghana,Guinea,Iceland,Ireland Republic of,Liberia,Madeira,Mali,Mauritania,Morocco,Northern Ireland,Principe Island,Sao Tome e Principe,Scotland,Senegal,Sierra Leone,St Helena,Togo,United Kingdom,Wales], [1.00, CET Central European, Albania,Algeria,Andorra,Angola,Austria,Balearic Islands,Belgium,Benin,Bosnia Hercegovina,Cameroon,Central African Rep,Chad,Congo,Czech Republic,Dahomey,Denmark,Equatorial Guinea,France,Gabon,Germany,Gibraltar,Hungary,Italy,Luxembourg,Macedonia,Mallorca Islands,Malta,Melilla,Monaco,Namibia,Netherlands,Niger,Nigeria,Norway,Poland,Portugal,San Marino,Slovakia,Slovenia,Spain,Sweden,Switzerland,Tunisia,Vatican City,Yugoslavia,Zaire Kinshasa Mbandaka,Croatia], [2.00, EET Eastern European,Belarus,Botswana,Bulgaria,Burundi,Cyprus,Egypt,Estonia,Finland,Greece,Israel,Jordan,Latvia,Lebanon,Lesotho,Libya,Lithuania,Malawi,Moldova,Moldovian Rep Pridnestrovye,Mozambique,Romania,Russian Federation zone one,Rwanda,South Africa,Sudan,Swaziland,Syria,Turkey,Ukraine,Zaire Haut Zaire,Zaire Kasai,Zaire Kivu,Zaire Shaba,Zambia,Zimbabwe], [3.00, Azerbaijan,Bahrain,Djibouti,Eritrea,Ethiopia,Iraq,Kenya,Kuwait,Madagascar,Mayotte,Qatar,Russian Federation zone two,Saudi Arabia,Somalia,Tanzania,Uganda,Yemen], [3.50, Iran], [4.00, Armenia,Georgia,Mauritius,Oman,Reunion,Russian Federation zone three,Seychelles,United Arab Emirates], [4.50, Afghanistan], [5.00, Kyrgyzstan,Maldives,Pakistan,Russian Federation zone four,Turkmenistan,Uzbekistan], [5.50, India,Sri Lanka], [5.75, Nepal], [6.00, Bangladesh,Bhutan,Kazakhstan,Russian Federation zone five,Tajikistan], [6.50, Myanmar], [7.00, Cambodia,Indonesia West,Laos,Russian Federation zone six,Thailand,Vietnam], [8.00, Australia Western,Brunei,China People's Rep,Hong Kong,Indonesia Central,Malaysia,Mongolia,Philippines,Russian Federation zone seven,Singapore,Taiwan], [9.00, YST: Yukon Standard,Indonesia East,Japan,Korea Dem Republic of,Korea Republic of,Palau,Russian Federation zone eight], [9.50, Australia Northern Territory,Australia South], [10.00, AHST: Alaska-Hawaii Standard,CAT: Central Alaska,HST: Hawaii Standard,Australia New South Wales,Australia Queensland,Australia Tasmania,Australia Victoria,Australian Capital Territory,Guam,Mariana Island,Northern Mariana Islands,Papua New Guinea,Russian Federation zone nine], [10.50, Australia Lord Howe Island], [11.00, Caroline Island,New Caledonia,New Hebrides,Ponape Island,Russian Federation zone ten,Solomon Islands,Vanuatu], [11.50, Norfolk Island], [12.00, IDLE: International Date Line East,Fiji,Kiribati,Kusaie,Kwajalein,Marshall Islands,Nauru Republic of,New Zealand,Pingelap,Russian Federation zone eleven,Tuvalu,Wake Island,Wallis and Futuna Islands], [13.00, Tonga], [14.00, Line Islands: Kiritibati] ]; Regards, On Sun, 02 Sep 2007 19:26:15 -0300,
[Flashcoders] coding a world clock
Just wanted to know where I could get the data to code world clocks in flash. Since flash works off the system clock am I able to get the time zone or do I need to use a web service that is available to make this happen? -- 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
RE: [Flashcoders] coding a world clock
Have a gander at the Date object ... it's all there. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Corban Baxter Sent: 31 August 2007 19:22 To: Flashcoders mailing list Subject: [Flashcoders] coding a world clock Just wanted to know where I could get the data to code world clocks in flash. Since flash works off the system clock am I able to get the time zone or do I need to use a web service that is available to make this happen? -- 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 ___ 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