[Time Zone] Errors with TimeZone

[Time Zone] Errors with TimeZone

  
Forge Component
(5)
Published on 11 Oct by André Vieira
5 votes
Published on 11 Oct by André Vieira
I am getting this error message:
The conversion could not be completed because the supplied DateTime did not have the Kind property set correctly.  For example, when the Kind property is DateTimeKind.Local, the source time zone must be TimeZoneInfo.Local

I found this post on the error:
http://stackoverflow.com/questions/1354516/having-problems-with-converting-my-datetime-to-utc

I was passing in the server time zone for the conversion, in my case Central Time ... should the code be updated so that the server time zone isn't getting passed in but just the correct value?
Hi Rebecca,

Can you share an example (OML) where this is happening? What is the timezone your server is running?

We are using the Date_Format action but we are getting the error above.  Our server is in Chicago and it is set to Central Time.
Ok,

Assuming you published the component in your server and that you still have the test page, do you get the same error in the test page?

I look into the error you sent and I have another suggestion, edit the extension and replace:

        /// <summary>

        /// 

        /// </summary>

        /// <param name="ssSourceDateTime"></param>

        /// <param name="ssSourceTimeZone"></param>

        /// <param name="ssDestinationTimeZone"></param>

        /// <param name="ssDateTime"></param>

        public void MssConvertFromTimeZone(DateTime ssSourceDateTime, string ssSourceTimeZone, string ssDestinationTimeZone, out DateTime ssDateTime)

        {

            ssDateTime = new DateTime(1900, 1, 1, 0, 0, 0);

            ssDateTime = TimeZoneInfo.ConvertTime(ssSourceDateTime, TimeZoneInfo.FindSystemTimeZoneById(ssSourceTimeZone), TimeZoneInfo.FindSystemTimeZoneById(ssDestinationTimeZone));            

        } // MssConvertFromTimeZone
 

with:

        /// <summary>

        /// 

        /// </summary>

        /// <param name="ssSourceDateTime"></param>

        /// <param name="ssSourceTimeZone"></param>

        /// <param name="ssDestinationTimeZone"></param>

        /// <param name="ssDateTime"></param>

        public void MssConvertFromTimeZone(DateTime ssSourceDateTime, string ssSourceTimeZone, string ssDestinationTimeZone, out DateTime ssDateTime)

        {

            ssDateTime = new DateTime(1900, 1, 1, 0, 0, 0);

            ssDateTime = TimeZoneInfo.ConvertTime(DateTime.SpecifyKind(ssSourceDateTime, DateTimeKind.Unspecified), TimeZoneInfo.FindSystemTimeZoneById(ssSourceTimeZone), TimeZoneInfo.FindSystemTimeZoneById(ssDestinationTimeZone));            

        } // MssConvertFromTimeZone


and try to see if it works.
This change fixed the problem with the conversion.  Sorry for the delay in responding, I was getting errors trying to publish them.