Okay,

So - it wasn't a JVM issue. Updating it did not change the results.

And Steve was right, in a way. But I still don't understand why it should be
this way.

First, Steve, I understand what you're saying about "whenever you display a
time." But in practice, I'm not displaying a time at all. I'm simply
creating a date/time value and adding a number of seconds to it, then
inserting into a database.

So to my way of thinking - and according to every doc I've ever read - the
dateAdd function should do exactly what you tell it to do: just add the
increments to the original date.

But what's happening DOES involve DST - though not the time zone. I don't
know why. It shouldn't. But it does, at least in CF9.

Try this for yourself: Daylight Savings Time began at 2:00 AM Eastern on
March 14, 2010. So run the following:

    <cfset myDate = createDate(2010,3,14) />
    <cfdump var="#myDate#" /><br><br>
    <cfset myDate2 = DateAdd('s',1271779666,myDate)>
    <cfdump var="#myDate2#" /><br><br>

myDate is two hours _before_ DST went into effect. On two different CF9
servers, one on EDT, the other on CDT, the result for myDate2 was:
{ts '2050-07-01 17:07:46'}

Now change the createDate to (2010,3,15) - _after_ DST went into effect. On
the same servers, the result was:
{ts '2050-07-02 16:07:46'}

The original date was changed by a day. But the result of the dateAdd
statement changed by 23 hours.

I wish I could test this on CF8 and/or 7, but the only servers with those
versions to which I have access are in Arizona, where they don't use DST.
Those servers return the 16:07:46 timestamp. But without having the machines
set to DST, I can't tell if CF is acting differently or not.

If someone has access to those versions on a DST machine, please try this
and see what you get. I'd really be curious to know if this is a CF9 thing.

Maybe I've just misunderstood how dateAdd works - although the docs simply
say "Adds units of time to a date." There's no mention of DST affecting it.
But it's certainly doing so.

So in brief: when you dateAdd, the result will be affected by DST  - at
least, based on whether your added timespan crosses the DST threshhold for
the current year. I have no idea if it tries to figure out whether the
resulting date/time is during DST or not.

In most instances, this might not even be noticed. But in my case, where I'm
receiving a timestamp from an external device as a Unix epoch time, then
converting it to a date/time object by adding the epoch time to the date of
1/1/1970, the result is not what I want, since all I'm trying to do is
recreate the time from the original device. The DST addition causes the
timestamp to be wrong by an hour.

Frustrating, but at least I now understand what's happening. Hope this will
help someone else avoid the same frustration.



-- 
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:333085
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to