Issue

When using a DateTime property of a SmartObject in SmartForms, the date/time may get stored incorrectly for certain historical dates.

Description

The DateTime property value is stored in the data source using the K2 server’s time zone and is displayed to the user based on the user's regional time zone setting. SmartForms uses the UTC date to load and save values but for backwards compatibly the UTC DateTime must be converted to the K2 server’s time before sending the data to the SmartObject. This is calculated by converting user's time > UTC time > SmartForms runtime server time (IIS) > K2 server > data source and vice versa.

Currently, it is not possible to prevent this automatic conversion when using a DateTime property of a SmartObject in SmartForms.

 Recent changes in Daylight Savings rules and the current implementation of browser JavaScript date/time calculations may incorrectly apply the current Daylight Savings rules to certain historic dates. The range of the incorrect calculation is limited to the Daylight Savings adjustment timespan, and only occurs with historic dates between the old start date/end date of Daylight Saving Time(DST) and the current start date/end date of DST.

 EXAMPLE OF ISSUE:

RuleStarts onEnds on
Daylight savings for dates 1986 - 2007 The first Sunday in April The last Sunday in October
Daylight savings for dates 2007 - current The second Sunday in March The first Sunday of November
Image

For example if a user in PST(-8) timezone selects 2006-03-15 00:00 in a Calendar control in a Form, the DST is incorrectly applied to the date, making the effective timezone -7. A UTC date is sent to the SmartForms server of 2006-03-15 07:00. The SmartForms server in the same timezone PST(-8) adjusts the date to server time to a value of 2006-03-14 23:00 (since here DST is calculated correctly on the historic date). This date is passed on to the SmartObject.

Workaround

Any one of the following options can be performed to resolve this issue:

  • Upgrade to Internet Explorer 10 - This issue is not applicable when using Internet Explorer 10. Visit the following link for more information: Spring Forward: Advancing Historical Date and Time Calculations on the Web.
  • Disable Auto Adjust in Windows - This option is only recommended for development environments where all components are on a single machine. Disable the automatic adjustment of Daylight Saving Time in Windows and the browser will not encounter the calculation issues.
    Important: This setting may affect other applications on the environment.

    Follow the steps below to disable the setting:
    1. Navigate to Start > All Programs > Control Panel > Date and Time > Change Time Zone
    2. Deselect the option as shown below
      Image
  • Use an expression to counteract the incorrect calculation - Modify existing SmartForms that have a data field to use an expression adding 2 hours to date fields within Forms before saving to the SmartObject. This will push any DST related date issues back into the correct date.
  • A custom control can be created. You may create a custom SmartForms control that counteracts the incorrect calculated dates. The following links might be useful when creating a custom control:

    Video - Building custom controls for K2 smartforms

    Developer Reference - Custom controls

    Existing custom controls

  • Correct the date in a custom SmartObject Service - Code can be written in the service broker to adjust the datetime to counteract the DST calculation error.