[flexcoders] Re: creating a World Clock and need a little help with the time and date

2008-07-21 Thread valdhor
Looking at the ASP .NET Date Tutorial at
http://www.easerve.com/developer/tutorials/asp-net-tutorials-dates.aspx
you can figure out how the dates work. Using that I came up with the
following which should help you out:

?xml version=1.0 encoding=utf-8?
mx:Application pageTitle=World Time
xmlns:mx=http://www.adobe.com/2006/mxml;
  width=100% height=100% backgroundSize=100% layout=vertical
horizontalAlign=left
  creationComplete=onComplete(event) backgroundColor=#BB 
 mx:Script
 ![CDATA[
 import mx.events.FlexEvent;

 [Bindable] private var dateText:String;
 private var CurrentTimeTicks:Number = 633516008019218750;

 public function onComplete(event:FlexEvent):void
 {
 var ticksSince1970:Number = CurrentTimeTicks -
NumTicksTo1970();
 var msSince1970:Number = ticksSince1970 / 1;

 var currentDate:Date = new Date(msSince1970);

 dateText = currentDate.toDateString() +   +
currentDate.toTimeString();
 }

 private function NumTicksTo1970():Number
 {
 var secondsPerDay:Number = 60 * 60 * 24;
 var numSecondsTo1970:Number = 0;

 for(var i:int = 1 ; i  1970 ; i++)
 {
 if((i % 4 == 0  i % 100 != 0) || i % 400 == 0)
 {
 numSecondsTo1970 += 366 * secondsPerDay;
 }
 else
 {
 numSecondsTo1970 += 365 * secondsPerDay;
 }
 }
 return 1000 * numSecondsTo1970;
 }
 ]]
 /mx:Script
 mx:Text text={dateText} /
/mx:Application




--- In flexcoders@yahoogroups.com, Mark [EMAIL PROTECTED] wrote:

 Actually the problem is that the CurrentTimeTicks and UtcOffsetTicks
 is returned in nanoseconds or increment of 100 nanoseconds so I
 can't use, new Date(CurrentTimeTicks);.  It returns as not a date
 Here's how the XML looks:


 TimeZoneInfo
   NameDateline Standard Time/Name
   DaylightNameDateline Daylight Time/DaylightName
   StandardNameDateline Standard Time/StandardName
   DisplayName(GMT-12:00) International Date Line
 West/DisplayName
   UtcOffsetTicks-4320/UtcOffsetTicks
   CurrentTimeTicks633516008019218750/CurrentTimeTicks
   IsInDaylightSavingfalse/IsInDaylightSaving
 /TimeZoneInfo





 --- In flexcoders@yahoogroups.com, Josh McDonald dznuts@
 wrote:
 
  All typed off the top of my head in gmail and untested:
 
  //Get a date for the UTC time numbers will match, but will be in
 local time
  var foreignTime:Date = new Date(CurrentTimeTicks);
 
  //Strip our current (local) offset (check my -/+ math!)
  foreignTime.time -= foreignTime.getTimeZoneOffset() * 1000 * 60;
 
  //Convert so the foreign value appears when getting the local
 value (again,
  check +/-)
  foreignTime.time += UtcOffsetTicks * 1000 * 60;
 
  if (IsDaylightSaving)
  foreignTime.time += 360;
 
  //Now if you fetch hours, minutes, seconds from foreignTime they
 should
  return the numbers you'd like.
 
  I've probably got a couple of +/- switched around, and if the
 ticks are
  seconds instead of ms knock off 3 zeros from some of those fields,
 but that
  should give you a starting point :)
 
  When you get the correct answer, please post it to the list in a
 follow-up
  to this thread.
 
  -Josh
 
  On Mon, Jul 14, 2008 at 11:34 PM, Mark markp.shopping_id@
 wrote:
 
   I asked this question going into a weekend so I wanted to re-ask
 it
   today and see if anyone has any ideas on how to work this?
  
   Thank You,
   Mark
  
  
  
  
 
 
  --
  Therefore, send not to know For whom the bell tolls. It tolls for
 thee.
 
  :: Josh 'G-Funk' McDonald
  :: 0437 221 380 :: josh@
 




[flexcoders] Re: creating a World Clock and need a little help with the time and date

2008-07-17 Thread Mark
I agree with you 100% Josh but the better ones want the all might $$ 
and my company isn't willing to pay for it, it's just nice to have.  
So I need to find a free one or give it up.  But I'm not willing to 
do that just yet...  soon, but not yet.  :-)

They do have have some pseudocode on the site but it really shows it 
using the DateTime in .Net.  And my understanding of that is that's 
built in so there's no convesions (although I could be wrong).

-M


--- In flexcoders@yahoogroups.com, Josh McDonald [EMAIL PROTECTED] 
wrote:

 Switch to a different web service, or call whoever provides it and 
get some
 documentation :)
 
 What the hell is 1AD? We haven't been keeping nice records since 
like 200AD
 or something.
 
 And do they count all the various leap seconds? What about that 
time when
 some pope rejigged the calendar and we disappeared like 13 days or
 something?
 
 Anybody proving information of such a monstrously non-standard 
fashion
 should also be providing some serious documentation and/or 
pseudocode.
 
 -Josh
 
 -- 
 Therefore, send not to know For whom the bell tolls. It tolls for 
thee.
 
 :: Josh 'G-Funk' McDonald
 :: 0437 221 380 :: [EMAIL PROTECTED]





[flexcoders] Re: creating a World Clock and need a little help with the time and date

2008-07-17 Thread Doug Lowder
Verify that you get midnight Jan 1, 1 AD from the following and 
you'll have the epoch adjustment value:

new Date( -6213559680 ).toUTCString()

Converting from timeticks returned by your webservice:

var epochAdjustment: Number = -6213559680;
var d: Date = new Date ( CurrentTimeTicks / 1 + epochAdjustment );
trace( d.toString() ); // client's local time


--- In flexcoders@yahoogroups.com, Mark [EMAIL PROTECTED] 
wrote:

 I agree with you 100% Josh but the better ones want the all might 
$$ 
 and my company isn't willing to pay for it, it's just nice to 
have.  
 So I need to find a free one or give it up.  But I'm not willing to 
 do that just yet...  soon, but not yet.  :-)
 
 They do have have some pseudocode on the site but it really shows 
it 
 using the DateTime in .Net.  And my understanding of that is that's 
 built in so there's no convesions (although I could be wrong).
 
 -M
 
 
 --- In flexcoders@yahoogroups.com, Josh McDonald dznuts@ 
 wrote:
 
  Switch to a different web service, or call whoever provides it 
and 
 get some
  documentation :)
  
  What the hell is 1AD? We haven't been keeping nice records since 
 like 200AD
  or something.
  
  And do they count all the various leap seconds? What about that 
 time when
  some pope rejigged the calendar and we disappeared like 13 days or
  something?
  
  Anybody proving information of such a monstrously non-standard 
 fashion
  should also be providing some serious documentation and/or 
 pseudocode.
  
  -Josh
  
  -- 
  Therefore, send not to know For whom the bell tolls. It tolls 
for 
 thee.
  
  :: Josh 'G-Funk' McDonald
  :: 0437 221 380 :: josh@
 





Re: [flexcoders] Re: creating a World Clock and need a little help with the time and date

2008-07-17 Thread Josh McDonald
The .net Date stuff will work sensibly and probably just like Flash's, so
I'd start with copying their code and work from there :)

-Josh

On Thu, Jul 17, 2008 at 10:37 PM, Mark [EMAIL PROTECTED] wrote:

 I agree with you 100% Josh but the better ones want the all might $$
 and my company isn't willing to pay for it, it's just nice to have.
 So I need to find a free one or give it up.  But I'm not willing to
 do that just yet...  soon, but not yet.  :-)

 They do have have some pseudocode on the site but it really shows it
 using the DateTime in .Net.  And my understanding of that is that's
 built in so there's no convesions (although I could be wrong).

 -M


 --- In flexcoders@yahoogroups.com, Josh McDonald [EMAIL PROTECTED]
 wrote:
 
  Switch to a different web service, or call whoever provides it and
 get some
  documentation :)
 
  What the hell is 1AD? We haven't been keeping nice records since
 like 200AD
  or something.
 
  And do they count all the various leap seconds? What about that
 time when
  some pope rejigged the calendar and we disappeared like 13 days or
  something?
 
  Anybody proving information of such a monstrously non-standard
 fashion
  should also be providing some serious documentation and/or
 pseudocode.
 
  -Josh
 
  --
  Therefore, send not to know For whom the bell tolls. It tolls for
 thee.
 
  :: Josh 'G-Funk' McDonald
  :: 0437 221 380 :: [EMAIL PROTECTED]
 



 

 --
 Flexcoders Mailing List
 FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Search Archives:
 http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
 Links






-- 
Therefore, send not to know For whom the bell tolls. It tolls for thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]


[flexcoders] Re: creating a World Clock and need a little help with the time and date

2008-07-16 Thread Mark
I tried a few things along those lines and not even getting close... 
really:

setDate =  new Date(nanoSeconds/1000 - new Date().getTime()); 
RETURNS Tue Jun 20 09:55:17 GMT-0400 1933

setDate =  new Date(nanoSeconds/(60*1000) - new Date().getTime
()); RETURNS Tue Jun 30 09:26:26 GMT-0400 1931

setDate =  new Date(nanoSeconds/(60*1000) - new Date
(1970,0,1,0,0,0,0).getTime()); RETURNS Mon Jan 12 19:17:43 GMT-0500 
1970

setDate =  new Date(nanoSeconds/1000 - new Date
(1970,0,1,0,0,0,0).getTime()); RETURNS Mon Jan 3 19:43:04 GMT-0500 
1972

There's a problem with the math but I'm just not able to find it.  
Any more help??  Maybe someone knows a different Web Service?

Thanks,
Mark



--- In flexcoders@yahoogroups.com, Doug Lowder [EMAIL PROTECTED] 
wrote:

 CurrentTimeTicks looks like a 100ns count from the year 1 AD.  You 
 could try:
 
  new Date( CurrentTimeTicks/1 - new Date().getTime() )
 
 Then use the Date.toString() or Date.toUTCString() method to 
examine 
 the result.  You may need to adjust if CurrentTimeTicks isn't 
 relative to UTC.
 
 Also, don't assume daylight savings time is always a one-hour 
 offset.  Some time zones work from increments of a quarter-hour.  
You 
 have the UtcOffsetTicks available to give you the correct offset.
 
 HTH,
 Doug
 
 
 --- In flexcoders@yahoogroups.com, Mark markp.shopping_id@ 
 wrote:
 
  Actually the problem is that the CurrentTimeTicks and 
 UtcOffsetTicks 
  is returned in nanoseconds or increment of 100 nanoseconds so I 
  can't use, new Date(CurrentTimeTicks);.  It returns as not a 
 date  
  Here's how the XML looks:
  
  
  TimeZoneInfo
NameDateline Standard Time/Name 
DaylightNameDateline Daylight Time/DaylightName 
StandardNameDateline Standard Time/StandardName 
DisplayName(GMT-12:00) International Date Line 
  West/DisplayName 
UtcOffsetTicks-4320/UtcOffsetTicks 
CurrentTimeTicks633516008019218750/CurrentTimeTicks 
IsInDaylightSavingfalse/IsInDaylightSaving 
  /TimeZoneInfo
  
  
  
  
  
  --- In flexcoders@yahoogroups.com, Josh McDonald dznuts@ 
  wrote:
  
   All typed off the top of my head in gmail and untested:
   
   //Get a date for the UTC time numbers will match, but will be 
in 
  local time
   var foreignTime:Date = new Date(CurrentTimeTicks);
   
   //Strip our current (local) offset (check my -/+ math!)
   foreignTime.time -= foreignTime.getTimeZoneOffset() * 1000 * 
60;
   
   //Convert so the foreign value appears when getting the local 
  value (again,
   check +/-)
   foreignTime.time += UtcOffsetTicks * 1000 * 60;
   
   if (IsDaylightSaving)
   foreignTime.time += 360;
   
   //Now if you fetch hours, minutes, seconds from foreignTime 
they 
  should
   return the numbers you'd like.
   
   I've probably got a couple of +/- switched around, and if the 
  ticks are
   seconds instead of ms knock off 3 zeros from some of those 
 fields, 
  but that
   should give you a starting point :)
   
   When you get the correct answer, please post it to the list in 
a 
  follow-up
   to this thread.
   
   -Josh
   
   On Mon, Jul 14, 2008 at 11:34 PM, Mark markp.shopping_id@ 
  wrote:
   
I asked this question going into a weekend so I wanted to re-
 ask 
  it
today and see if anyone has any ideas on how to work this?
   
Thank You,
Mark
   
   
   
   
   
   
   -- 
   Therefore, send not to know For whom the bell tolls. It tolls 
 for 
  thee.
   
   :: Josh 'G-Funk' McDonald
   :: 0437 221 380 :: josh@
  
 





[flexcoders] Re: creating a World Clock and need a little help with the time and date

2008-07-16 Thread Doug Lowder
Sorry, I missed a parameter in there - that should have been new Date
(0).

  new Date( CurrentTimeTicks / 1 - new Date(0).getTime() )

If you truly have a 100ns count since 1 AD as CurrentTimeTicks (the 
math works out, but you should still verify that with the webservice 
if possible), then you would need to adjust for the difference 
between CurrentTimeTicks=0 (presumably Jan 1, 1 AD 00:00:00 UTC) and 
Date(0) (Jan 1, 1970 00:00:00 UTC) and pass that to Date() after 
converting to milliseconds along the way.


--- In flexcoders@yahoogroups.com, Mark [EMAIL PROTECTED] 
wrote:

 I tried a few things along those lines and not even getting 
close... 
 really:
 
 setDate =  new Date(nanoSeconds/1000 - new Date().getTime()); 
 RETURNS Tue Jun 20 09:55:17 GMT-0400 1933
 
 setDate =  new Date(nanoSeconds/(60*1000) - new Date().getTime
 ()); RETURNS Tue Jun 30 09:26:26 GMT-0400 1931
 
 setDate =  new Date(nanoSeconds/(60*1000) - new Date
 (1970,0,1,0,0,0,0).getTime()); RETURNS Mon Jan 12 19:17:43 GMT-0500 
 1970
 
 setDate =  new Date(nanoSeconds/1000 - new Date
 (1970,0,1,0,0,0,0).getTime()); RETURNS Mon Jan 3 19:43:04 GMT-0500 
 1972
 
 There's a problem with the math but I'm just not able to find it.  
 Any more help??  Maybe someone knows a different Web Service?
 
 Thanks,
 Mark
 
 
 
 --- In flexcoders@yahoogroups.com, Doug Lowder douglowder@ 
 wrote:
 
  CurrentTimeTicks looks like a 100ns count from the year 1 AD.  
You 
  could try:
  
   new Date( CurrentTimeTicks/1 - new Date().getTime() )
  
  Then use the Date.toString() or Date.toUTCString() method to 
 examine 
  the result.  You may need to adjust if CurrentTimeTicks isn't 
  relative to UTC.
  
  Also, don't assume daylight savings time is always a one-hour 
  offset.  Some time zones work from increments of a quarter-hour.  
 You 
  have the UtcOffsetTicks available to give you the correct offset.
  
  HTH,
  Doug
  
  
  --- In flexcoders@yahoogroups.com, Mark markp.shopping_id@ 
  wrote:
  
   Actually the problem is that the CurrentTimeTicks and 
  UtcOffsetTicks 
   is returned in nanoseconds or increment of 100 nanoseconds so I 
   can't use, new Date(CurrentTimeTicks);.  It returns as not a 
  date  
   Here's how the XML looks:
   
   
   TimeZoneInfo
 NameDateline Standard Time/Name 
 DaylightNameDateline Daylight Time/DaylightName 
 StandardNameDateline Standard Time/StandardName 
 DisplayName(GMT-12:00) International Date Line 
   West/DisplayName 
 UtcOffsetTicks-4320/UtcOffsetTicks 
 CurrentTimeTicks633516008019218750/CurrentTimeTicks 
 IsInDaylightSavingfalse/IsInDaylightSaving 
   /TimeZoneInfo
   
   
   
   
   
   --- In flexcoders@yahoogroups.com, Josh McDonald dznuts@ 
   wrote:
   
All typed off the top of my head in gmail and untested:

//Get a date for the UTC time numbers will match, but will be 
 in 
   local time
var foreignTime:Date = new Date(CurrentTimeTicks);

//Strip our current (local) offset (check my -/+ math!)
foreignTime.time -= foreignTime.getTimeZoneOffset() * 1000 * 
 60;

//Convert so the foreign value appears when getting the local 
   value (again,
check +/-)
foreignTime.time += UtcOffsetTicks * 1000 * 60;

if (IsDaylightSaving)
foreignTime.time += 360;

//Now if you fetch hours, minutes, seconds from foreignTime 
 they 
   should
return the numbers you'd like.

I've probably got a couple of +/- switched around, and if the 
   ticks are
seconds instead of ms knock off 3 zeros from some of those 
  fields, 
   but that
should give you a starting point :)

When you get the correct answer, please post it to the list 
in 
 a 
   follow-up
to this thread.

-Josh

On Mon, Jul 14, 2008 at 11:34 PM, Mark markp.shopping_id@ 
   wrote:

 I asked this question going into a weekend so I wanted to 
re-
  ask 
   it
 today and see if anyone has any ideas on how to work this?

 Thank You,
 Mark






-- 
Therefore, send not to know For whom the bell tolls. It 
tolls 
  for 
   thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: josh@
   
  
 





[flexcoders] Re: creating a World Clock and need a little help with the time and date

2008-07-16 Thread Doug Lowder
Bah.  Obviously I'm not testing any of this myself - I'm leaving that 
up to you!

A call to new Date(0).getTime() will just return 0, so that won't 
work.  What you need is the number of milliseconds *between* 1 AD 
00:00:00 UTC and Jan 1, 1970 00:00:00 UTC.  I don't think there's a 
way to use ActionScript's Date class to determine this.  You can use 
a different technology (Java's GregorianCalendar class, for example) 
or just extrapolate an approximation of that value.  It will be a 
constant once determined.

(1970-1 = 1969) yrs * 365.25 days/yr * 24 hrs/day * 3600 secs/hr * 
1000 ms/sec * 1 timeticks/ms = 6213691440 timeticks 
(100ns)

(This is definitely an approximation, since there aren't precisely 
365.25 days per year, and it doesn't account for leap seconds, etc., 
but it might be close enough)

Adjust CurrentTimeTicks by that constant and pass it to Date(), 
converting to milliseconds somewhere along the way:

new Date( (CurrentTimeTicks - 6213691440) / 1 )
or:
new Date( CurrentTimeTicks/1 - 6213691440 )

Hope that gets you a bit closer to a solution.


--- In flexcoders@yahoogroups.com, Doug Lowder [EMAIL PROTECTED] 
wrote:

 Sorry, I missed a parameter in there - that should have been new 
Date
 (0).
 
   new Date( CurrentTimeTicks / 1 - new Date(0).getTime() )
 
 If you truly have a 100ns count since 1 AD as CurrentTimeTicks (the 
 math works out, but you should still verify that with the 
webservice 
 if possible), then you would need to adjust for the difference 
 between CurrentTimeTicks=0 (presumably Jan 1, 1 AD 00:00:00 UTC) 
and 
 Date(0) (Jan 1, 1970 00:00:00 UTC) and pass that to Date() after 
 converting to milliseconds along the way.
 
 
 --- In flexcoders@yahoogroups.com, Mark markp.shopping_id@ 
 wrote:
 
  I tried a few things along those lines and not even getting 
 close... 
  really:
  
  setDate =  new Date(nanoSeconds/1000 - new Date().getTime()); 
  RETURNS Tue Jun 20 09:55:17 GMT-0400 1933
  
  setDate =  new Date(nanoSeconds/(60*1000) - new Date().getTime
  ()); RETURNS Tue Jun 30 09:26:26 GMT-0400 1931
  
  setDate =  new Date(nanoSeconds/(60*1000) - new Date
  (1970,0,1,0,0,0,0).getTime()); RETURNS Mon Jan 12 19:17:43 GMT-
0500 
  1970
  
  setDate =  new Date(nanoSeconds/1000 - new Date
  (1970,0,1,0,0,0,0).getTime()); RETURNS Mon Jan 3 19:43:04 GMT-
0500 
  1972
  
  There's a problem with the math but I'm just not able to find 
it.  
  Any more help??  Maybe someone knows a different Web Service?
  
  Thanks,
  Mark
  
  
  
  --- In flexcoders@yahoogroups.com, Doug Lowder douglowder@ 
  wrote:
  
   CurrentTimeTicks looks like a 100ns count from the year 1 AD.  
 You 
   could try:
   
new Date( CurrentTimeTicks/1 - new Date().getTime() )
   
   Then use the Date.toString() or Date.toUTCString() method to 
  examine 
   the result.  You may need to adjust if CurrentTimeTicks isn't 
   relative to UTC.
   
   Also, don't assume daylight savings time is always a one-hour 
   offset.  Some time zones work from increments of a quarter-
hour.  
  You 
   have the UtcOffsetTicks available to give you the correct 
offset.
   
   HTH,
   Doug
   
   
   --- In flexcoders@yahoogroups.com, Mark markp.shopping_id@ 
   wrote:
   
Actually the problem is that the CurrentTimeTicks and 
   UtcOffsetTicks 
is returned in nanoseconds or increment of 100 nanoseconds so 
I 
can't use, new Date(CurrentTimeTicks);.  It returns as not a 
   date  
Here's how the XML looks:


TimeZoneInfo
  NameDateline Standard Time/Name 
  DaylightNameDateline Daylight Time/DaylightName 
  StandardNameDateline Standard Time/StandardName 
  DisplayName(GMT-12:00) International Date Line 
West/DisplayName 
  UtcOffsetTicks-4320/UtcOffsetTicks 
  CurrentTimeTicks633516008019218750/CurrentTimeTicks 
  IsInDaylightSavingfalse/IsInDaylightSaving 
/TimeZoneInfo





--- In flexcoders@yahoogroups.com, Josh McDonald dznuts@ 
wrote:

 All typed off the top of my head in gmail and untested:
 
 //Get a date for the UTC time numbers will match, but will 
be 
  in 
local time
 var foreignTime:Date = new Date(CurrentTimeTicks);
 
 //Strip our current (local) offset (check my -/+ math!)
 foreignTime.time -= foreignTime.getTimeZoneOffset() * 1000 
* 
  60;
 
 //Convert so the foreign value appears when getting the 
local 
value (again,
 check +/-)
 foreignTime.time += UtcOffsetTicks * 1000 * 60;
 
 if (IsDaylightSaving)
 foreignTime.time += 360;
 
 //Now if you fetch hours, minutes, seconds from foreignTime 
  they 
should
 return the numbers you'd like.
 
 I've probably got a couple of +/- switched around, and if 
the 
ticks are
 seconds instead of ms knock off 3 zeros from some of those 
   fields, 
but that
 should give you a starting point :)

Re: [flexcoders] Re: creating a World Clock and need a little help with the time and date

2008-07-16 Thread Josh McDonald
Switch to a different web service, or call whoever provides it and get some
documentation :)

What the hell is 1AD? We haven't been keeping nice records since like 200AD
or something.

And do they count all the various leap seconds? What about that time when
some pope rejigged the calendar and we disappeared like 13 days or
something?

Anybody proving information of such a monstrously non-standard fashion
should also be providing some serious documentation and/or pseudocode.

-Josh

-- 
Therefore, send not to know For whom the bell tolls. It tolls for thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]


[flexcoders] Re: creating a World Clock and need a little help with the time and date

2008-07-14 Thread Mark
I asked this question going into a weekend so I wanted to re-ask it 
today and see if anyone has any ideas on how to work this?

Thank You,
Mark


--- In flexcoders@yahoogroups.com, Mark [EMAIL PROTECTED] 
wrote:

 The Web Service I found returns a few key pieces of data but I'm 
not 
 sure how to convert this in AS.  Here's what it's returning:
 
 UtcOffsetTicks
 CurrentTimeTicks
 IsDaylightSaving
 
 I believe the first two are returning the time and/or date in 
 nanoseconds but I'm not 100%, while the 3rd is true/false.  Can 
anyone 
 help with the math/AS here?
 
 This is the Service:
 
 
http://www.quantumsoftware.com.au/WorldTimeWebService/WorldTimeWebSer
vi
 ce.asmx
 
 Thank You,
 Mark





Re: [flexcoders] Re: creating a World Clock and need a little help with the time and date

2008-07-14 Thread Josh McDonald
All typed off the top of my head in gmail and untested:

//Get a date for the UTC time numbers will match, but will be in local time
var foreignTime:Date = new Date(CurrentTimeTicks);

//Strip our current (local) offset (check my -/+ math!)
foreignTime.time -= foreignTime.getTimeZoneOffset() * 1000 * 60;

//Convert so the foreign value appears when getting the local value (again,
check +/-)
foreignTime.time += UtcOffsetTicks * 1000 * 60;

if (IsDaylightSaving)
foreignTime.time += 360;

//Now if you fetch hours, minutes, seconds from foreignTime they should
return the numbers you'd like.

I've probably got a couple of +/- switched around, and if the ticks are
seconds instead of ms knock off 3 zeros from some of those fields, but that
should give you a starting point :)

When you get the correct answer, please post it to the list in a follow-up
to this thread.

-Josh

On Mon, Jul 14, 2008 at 11:34 PM, Mark [EMAIL PROTECTED] wrote:

 I asked this question going into a weekend so I wanted to re-ask it
 today and see if anyone has any ideas on how to work this?

 Thank You,
 Mark






-- 
Therefore, send not to know For whom the bell tolls. It tolls for thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]


[flexcoders] Re: creating a World Clock and need a little help with the time and date

2008-07-14 Thread Mark
Actually the problem is that the CurrentTimeTicks and UtcOffsetTicks 
is returned in nanoseconds or increment of 100 nanoseconds so I 
can't use, new Date(CurrentTimeTicks);.  It returns as not a date  
Here's how the XML looks:


TimeZoneInfo
  NameDateline Standard Time/Name 
  DaylightNameDateline Daylight Time/DaylightName 
  StandardNameDateline Standard Time/StandardName 
  DisplayName(GMT-12:00) International Date Line 
West/DisplayName 
  UtcOffsetTicks-4320/UtcOffsetTicks 
  CurrentTimeTicks633516008019218750/CurrentTimeTicks 
  IsInDaylightSavingfalse/IsInDaylightSaving 
/TimeZoneInfo





--- In flexcoders@yahoogroups.com, Josh McDonald [EMAIL PROTECTED] 
wrote:

 All typed off the top of my head in gmail and untested:
 
 //Get a date for the UTC time numbers will match, but will be in 
local time
 var foreignTime:Date = new Date(CurrentTimeTicks);
 
 //Strip our current (local) offset (check my -/+ math!)
 foreignTime.time -= foreignTime.getTimeZoneOffset() * 1000 * 60;
 
 //Convert so the foreign value appears when getting the local 
value (again,
 check +/-)
 foreignTime.time += UtcOffsetTicks * 1000 * 60;
 
 if (IsDaylightSaving)
 foreignTime.time += 360;
 
 //Now if you fetch hours, minutes, seconds from foreignTime they 
should
 return the numbers you'd like.
 
 I've probably got a couple of +/- switched around, and if the 
ticks are
 seconds instead of ms knock off 3 zeros from some of those fields, 
but that
 should give you a starting point :)
 
 When you get the correct answer, please post it to the list in a 
follow-up
 to this thread.
 
 -Josh
 
 On Mon, Jul 14, 2008 at 11:34 PM, Mark [EMAIL PROTECTED] 
wrote:
 
  I asked this question going into a weekend so I wanted to re-ask 
it
  today and see if anyone has any ideas on how to work this?
 
  Thank You,
  Mark
 
 
 
 
 
 
 -- 
 Therefore, send not to know For whom the bell tolls. It tolls for 
thee.
 
 :: Josh 'G-Funk' McDonald
 :: 0437 221 380 :: [EMAIL PROTECTED]





[flexcoders] Re: creating a World Clock and need a little help with the time and date

2008-07-14 Thread Doug Lowder
CurrentTimeTicks looks like a 100ns count from the year 1 AD.  You 
could try:

 new Date( CurrentTimeTicks/1 - new Date().getTime() )

Then use the Date.toString() or Date.toUTCString() method to examine 
the result.  You may need to adjust if CurrentTimeTicks isn't 
relative to UTC.

Also, don't assume daylight savings time is always a one-hour 
offset.  Some time zones work from increments of a quarter-hour.  You 
have the UtcOffsetTicks available to give you the correct offset.

HTH,
Doug


--- In flexcoders@yahoogroups.com, Mark [EMAIL PROTECTED] 
wrote:

 Actually the problem is that the CurrentTimeTicks and 
UtcOffsetTicks 
 is returned in nanoseconds or increment of 100 nanoseconds so I 
 can't use, new Date(CurrentTimeTicks);.  It returns as not a 
date  
 Here's how the XML looks:
 
 
 TimeZoneInfo
   NameDateline Standard Time/Name 
   DaylightNameDateline Daylight Time/DaylightName 
   StandardNameDateline Standard Time/StandardName 
   DisplayName(GMT-12:00) International Date Line 
 West/DisplayName 
   UtcOffsetTicks-4320/UtcOffsetTicks 
   CurrentTimeTicks633516008019218750/CurrentTimeTicks 
   IsInDaylightSavingfalse/IsInDaylightSaving 
 /TimeZoneInfo
 
 
 
 
 
 --- In flexcoders@yahoogroups.com, Josh McDonald dznuts@ 
 wrote:
 
  All typed off the top of my head in gmail and untested:
  
  //Get a date for the UTC time numbers will match, but will be in 
 local time
  var foreignTime:Date = new Date(CurrentTimeTicks);
  
  //Strip our current (local) offset (check my -/+ math!)
  foreignTime.time -= foreignTime.getTimeZoneOffset() * 1000 * 60;
  
  //Convert so the foreign value appears when getting the local 
 value (again,
  check +/-)
  foreignTime.time += UtcOffsetTicks * 1000 * 60;
  
  if (IsDaylightSaving)
  foreignTime.time += 360;
  
  //Now if you fetch hours, minutes, seconds from foreignTime they 
 should
  return the numbers you'd like.
  
  I've probably got a couple of +/- switched around, and if the 
 ticks are
  seconds instead of ms knock off 3 zeros from some of those 
fields, 
 but that
  should give you a starting point :)
  
  When you get the correct answer, please post it to the list in a 
 follow-up
  to this thread.
  
  -Josh
  
  On Mon, Jul 14, 2008 at 11:34 PM, Mark markp.shopping_id@ 
 wrote:
  
   I asked this question going into a weekend so I wanted to re-
ask 
 it
   today and see if anyone has any ideas on how to work this?
  
   Thank You,
   Mark
  
  
  
  
  
  
  -- 
  Therefore, send not to know For whom the bell tolls. It tolls 
for 
 thee.
  
  :: Josh 'G-Funk' McDonald
  :: 0437 221 380 :: josh@