17 Replies Latest reply on Mar 23, 2007 8:28 AM by Karthik_Nataraj

    WDDX Deserializes the date wrongly

    Karthik_Nataraj
      The code given below in written in VB but uses the wddx_com library of CFMX 6.1. I have CFM code that serializes an array of date and passes that to a VB component. The VB component deserializes and then consumes that. The issue I have is, I just sent one element in the array selecting the date 16-Mar-2007 08:00:00 AM in the EST time zone (i.e. 2007-3-16T8:0:0-5:0). But the VB programme consumes the date as 16-Mar-2007 09:00:00 AM in the EST time zone. I am clue less why it adds an hour.

      <!--- cf sample code starts --->
      <cfset ArrDateTimes[1] = ParseDateTime(Form.fld_DateTime)>
      <cfwddx action="CFML2WDDX" input="#ArrDateTimes#" output="wddxDateTimes">
      <cfobject class="MyVBComponent.clsDateTime" action="Create" name="VBDateTime">
      <cfset test = VBDateTime.GetDateTime(wddxDateTimes)>
      <!--- cf sample code ends --->

      <!--- vb sample code starts --->
      Dim objWddxDeser As New WDDXDeserializer
      Dim varValue As Variant
      varValue = objWddxDeser.deserialize("<wddxPacket version='1.0'><header/><data><array length='1'><dateTime>2007-3-16T8:0:0-5:0</dateTime></array></data></wddxPacket>")
      MsgBox CStr(varValue(0))
      <!--- vb sample code ends --->

      I have the Windows 2000 DST patch ( http://support.microsoft.com/kb/914387/) applied and also the JDK US DST Time zone Update Tool - 1.1 (latest released on Mar 8th) applied for the JRE shipped with Coldfusion MX 6.1. I don't have a separate JRE or JDK installed in the box and the date time is working perfectly in all other places of the application.

      Am I missing something or is it a bug with the library WDDX_COMLib 1.0. Any help greatly appreciated.
        • 1. WDDX Deserializes the date wrongly
          BKBK Adobe Community Professional & MVP
          Apply
          - in Coldfusion: <cfwddx usetimezoneinfo="yes">
          - at the very beginning of the script: objWddxDeser.usetimezoneinfo=true; or this.usetimezoneinfo=true;


          • 2. Re: WDDX Deserializes the date wrongly
            Karthik_Nataraj Level 1
            Thanks for your response. ColdFusion documentation says the default value for useTimeZoneInfo is "Yes". Still I added the attribute and I am getting the same error. In ColdFusion I tried to serialize and deserialize and got the proper date, but when the date is serialized in ColdFusion and deserialized in a VB program, the issue occurs.

            I couldn't set or even get the value for the attribute "useTimeZoneInfo" in the vb program. The component that is referred to create the object of WDDXDeserializer is at "C:\WINNT\system32\wddx_com.dll". The Company Name of this dll is empty & the version specifies its 1.0.0.1. Is there an higher version available? Is the attribute "useTimeZoneInfo" by default "No" when we create an instance of the object in vb.
            • 3. Re: WDDX Deserializes the date wrongly
              insuractive Level 3
              Just out of curiosity, what is the value of the date/time inserted into the WDDX packet (the actual value in the XML code). Does it match the CF value or the .NET value?
              • 4. Re: WDDX Deserializes the date wrongly
                Karthik_Nataraj Level 1
                The actual value in the XML (2007-3-16T8:0:0-5:0) is the serialized date of 16th Mar 2007 8:00 AM EST. And "-5" here refers to the timezone difference from GMT. I have an interesting question there too, how the system treats it to the GMT-5 timezones like "Bogota, Lima, Quito" or "Eastern Time (US & Canada)" or "Indiana (East)".
                • 5. Re: WDDX Deserializes the date wrongly
                  insuractive Level 3
                  Do you get the same value if you set useTimeZoneInfo to No?
                  • 6. Re: WDDX Deserializes the date wrongly
                    Karthik_Nataraj Level 1
                    If you use "useTimeZoneInfo" as "No" the timezone information is ignored and the date is converted to GMT.

                    i.e. the output is {ts '2007-03-16 03:00:00'}. I haven't sent the serialized data to vb component and debugged it. When I get that I will update it how the serialized data will look like.
                    • 7. Re: WDDX Deserializes the date wrongly
                      BKBK Adobe Community Professional & MVP
                      I've just read this in the MX7 livedocs on WDDX

                      When the cfwddx tag deserializes WDDX to CFML, it automatically uses available time zone information, and converts date-time values to local time. In this way, you do not need to worry about the details of time zone conversions.

                      However, when the JavaScript objects supplied with ColdFusion deserialize WDDX to JavaScript expressions, they do not use time zone information, because in JavaScript it is difficult to determine the time zone of the browser.


                      I would imagine that the same applies to VBScript.

                      • 8. Re: WDDX Deserializes the date wrongly
                        BKBK Adobe Community Professional & MVP
                        <cfwddx action="CFML2WDDX" input="#ArrDateTimes#" output="wddxDateTimes">
                        ...
                        varValue = objWddxDeser.deserialize("<wddxPacket version='1.0'><header/><data><array length='1'><dateTime>2007-3-16T8:0:0-5:0</dateTime></array></data></wddxPacket>")


                        Why don't you test with something like this?

                        Coldfusion
                        =========
                        <cfwddx action="CFML2WDDX" input="#varContainingDatetime#" output="wddxVarContainingDatetime">

                        VBScript
                        =======
                        varValue = objWddxDeser.deserialize(wddxVarContainingDatetime)

                        • 9. Re: WDDX Deserializes the date wrongly
                          insuractive Level 3
                          Did you ever send the serialized data to VB with the userTimeZoneInfo set to No? What was the result?
                          • 10. Re: WDDX Deserializes the date wrongly
                            Level 7
                            > The actual value in the XML (2007-3-16T8:0:0-5:0) is the serialized date of
                            > 16th Mar 2007 8:00 AM EST. And "-5" here refers to the timezone difference from
                            > GMT. I have an interesting question there too, how the system treats it to the
                            > GMT-5 timezones like "Bogota, Lima, Quito" or "Eastern Time (US & Canada)" or
                            > "Indiana (East)".

                            It doesn't need to differentiate. It's capturing a moment in time: the
                            data was serialised at 8am on 16/3/2007, at which point the local time
                            (currently EST) was -5hrs offset from Zulu. The different TZs you mention
                            are only significant when considering a range of times, and when the DLS
                            rules differ from one zone to the other. DLS *rules* are irrelevant when
                            taking a snapshot. At the time of the snapshot, the local time differs
                            from GMT by five hours.

                            As for your problem - for testing purposes - what happens if you treat the
                            WDDX as XML, xpath the timestamp string out, and do a VB equivalent of
                            parseDateTime() on it?

                            --
                            Adam
                            • 11. Re: WDDX Deserializes the date wrongly
                              Karthik_Nataraj Level 1
                              When I use the "userTimeZoneInfo" as "No" this is what the serilized data in VB looks like
                              <wddxPacket version='1.0'><header/><data><array length='1'><dateTime>2007-3-21T8:0:0</dateTime></array></data></wddxPacket>

                              When deserialized it gets converted to 3/21/2007 4:00:00 AM. For testing purpose I even converted the array to send only one data by commenting out the other portions and the serialized data in VB looked like
                              <wddxPacket version='1.0'><header/><data><dateTime>2007-3-21T8:0:0-5:0</dateTime></data></wddxPacket>

                              When deserialized it again got converted to 3/21/2007 9:00:00 AM.

                              Regarding treating WDDX serialized data as string and retrieving the date array values as string and manipulating them to date is theoretically possible. But what if users are in different timezone playing with my multidate calendar? Also the vb component is generic to handle array of serialized data and save them to a variant. This variant is again then passed to vc component for further business processing. The array of data can be of any type and still I can find whether it's date with some regular expression validation. I would prefer a fix in the wddx component to handle the daylight saving with a property that is exposed to programmers in javascript, vbscript or VB. Handling the serialization and deserialization in coldfusion alone doesn't suffice the need of wddx.
                              • 12. Re: WDDX Deserializes the date wrongly
                                Level 7
                                > Regarding treating WDDX serialized data as string and retrieving the date
                                > array values as string and manipulating them to date is theoretically possible.

                                I wasn't suggesting it as a solution, I just want to know what it DOES.
                                What date do you end up with if you bypass the WDDX process and simply
                                parse the datetime string into a date? I'm trying to ascertain whether
                                it's the WDDX process that mungs the date, or whether it's how VB is
                                interpretting that date string.

                                --
                                Adam
                                • 13. Re: WDDX Deserializes the date wrongly
                                  Karthik_Nataraj Level 1
                                  Dim strDate As String
                                  Dim dtDate As Date
                                  strDate = "2007-03-16 8:0:0"
                                  dtDate = CDate(strDate)
                                  MsgBox CStr(dtDate)

                                  The result is "3/16/2007 8:00:00 AM". It is not a VB date conversion issue that is why I replied it is possible to take the string date, parse and convert it to a date.
                                  • 14. Re: WDDX Deserializes the date wrongly
                                    Level 7
                                    This
                                    > "2007-03-16 8:0:0"

                                    ia not this:

                                    2007-3-16T8:0:0-5:0

                                    Parse *THAT* string.

                                    --
                                    Adam
                                    • 15. Re: WDDX Deserializes the date wrongly
                                      Karthik_Nataraj Level 1
                                      Sorry I am not aware of parsing that string exactly to date in VB. In VB .Net you have a DateTime.Parse to do the job, but in VB I am not sure. Please let me know how to do it.
                                      • 16. Re: WDDX Deserializes the date wrongly
                                        Level 7
                                        > Sorry I am not aware of parsing that string exactly to date in VB. In VB .Net you have a DateTime.Parse to do the job, but in VB I am not sure. Please let me know how to do it.

                                        I wouldn't have a clue mate: I'm only a CF developer. You're the one using
                                        VB...

                                        --
                                        Adam
                                        • 17. Re: WDDX Deserializes the date wrongly
                                          Karthik_Nataraj Level 1
                                          As per my knowledge, it's not feasible to consider the whole serialized data string "2007-3-16T8:0:0-5:0" as is in VB. That is the reason we deserialize and pick the date.