You need to sign in to do that
Don't have an account?
Shin
Flex Toolkit : dateTimeToString problem
I'm now start using flex toolkit for apex, and had a trouble while
creating record with dateTime attribute. For example, following code doesn't work properly.
Code:
First I thought it might be caused by some bugs in flex toolkit manipulating timezone offset (because my current timezone is +9:00 (JST), and the incorrect insertion always happens before 9:00 a.m. ). Following test code might explain this (I'm using Flex Toolkit PR3.6)
Code:
Code:
"2007-07-30T08:20:08.95-15:00" is considered as "2007-07-31T08:20:08.95+09:00", so it's not a valid dateTime format for the designated date.
Code:
var event1:SObject = new SObject('Event');Both records were successfully inserted, but not correctly for event #2. The date of event #2 became next day, 2007-07-31.
event1.Subject = 'event #1';
event1.ActivityDateTime = new Date(2007, 7, 30, 9, 0, 0); // 2007-07-30:09:00:00+9:00
event1.DurationInMinutes = 60;
var event2:SObject = new SObject('Event');
event2.Subject = 'event #2';
event2.ActivityDateTime = new Date(2007, 7, 30, 8, 0, 0); // 2007-07-30:08:00:00+9:00
event2.DurationInMinutes = 60;
conn.create([ event1, event2 ], new AsyncResponder(handleResult));
First I thought it might be caused by some bugs in flex toolkit manipulating timezone offset (because my current timezone is +9:00 (JST), and the incorrect insertion always happens before 9:00 a.m. ). Following test code might explain this (I'm using Flex Toolkit PR3.6)
Code:
<—xml version="1.0" encoding="utf-8"–>and output is here:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
applicationComplete="test()" >
<mx:Script>
<![CDATA[
import com.salesforce.Util;
private function test():void {
var d:Date = new Date();
for (var i:int=0; i<24; i++) {
output.text += Util.dateTimeToString(d)+'\n';
d.hours--;
}
}
]]>
</mx:Script>
<mx:TextArea id="output" width="100%" height="800"/>
</mx:Application>
Code:
2007-07-30T19:20:08.95+09:00From the mid of the output line you can see timezone offset becomes +9:00 to -15:00, but the date itself is still remains 2007-07-30.
2007-07-30T18:20:08.95+09:00
2007-07-30T17:20:08.95+09:00
2007-07-30T16:20:08.95+09:00
2007-07-30T15:20:08.95+09:00
2007-07-30T14:20:08.95+09:00
2007-07-30T13:20:08.95+09:00
2007-07-30T12:20:08.95+09:00
2007-07-30T11:20:08.95+09:00
2007-07-30T10:20:08.95+09:00
2007-07-30T09:20:08.95+09:00
2007-07-30T08:20:08.95-15:00
2007-07-30T07:20:08.95-15:00
2007-07-30T06:20:08.95-15:00
2007-07-30T05:20:08.95-15:00
2007-07-30T04:20:08.95-15:00
2007-07-30T03:20:08.95-15:00
2007-07-30T02:20:08.95-15:00
2007-07-30T01:20:08.95-15:00
2007-07-30T00:20:08.95-15:00
2007-07-29T23:20:08.95+09:00
2007-07-29T22:20:08.95+09:00
2007-07-29T21:20:08.95+09:00
2007-07-29T20:20:08.95+09:00
"2007-07-30T08:20:08.95-15:00" is considered as "2007-07-31T08:20:08.95+09:00", so it's not a valid dateTime format for the designated date.
i don't see the problem in my timezone but if i set it to JST, i see the problem
thanks for reporting this.
Message Edited by Ron Hess on 07-30-2007 11:06 AM
https://sforce.svn.sourceforge.net/svnroot/sforce/mavericks
the fix looks like this :
Code:
Not sure when i can release a complete library, perhaps later this week.
I really apreciate your reporting issues like this, hope to see you at Dreamforce !
Shinichi
Shinichi