Fix Hours Offset on Direct Answer Cards (May '21 Release)

With this update, we corrected a bug where the user’s current time zone was not being taken into account when displaying the hours status on Direct Answers.

Upgrade Implications: If you forked your direct answer card to create a custom one, you should refork to get this update (it’s in the component.js file).

Alternatively, update the hours case in the component.js.

Replace

  case 'hours':
        if (isArray) {
          arrayValue = answer.value.map((value) => `<div>${Formatter.openStatus({hours: value})}</div>`);
        } else {
          regularValue = `<div>${Formatter.openStatus({hours: answer.value})}</div>`;
       }

with

case 'hours':
        const timezoneOffsetForLocation = relatedItem?.data?.fieldValues?.timeZoneUtcOffset;
        if (isArray) {
          arrayValue = answer.value.map((value) => {
            const openStatus = Formatter.openStatus({
              hours: value,
              timeZoneUtcOffset: timezoneOffsetForLocation
            });
            return `<div>${openStatus}</div>`;
          });
        } else {
          const openStatus = Formatter.openStatus({
            hours: answer.value,
            timeZoneUtcOffset: timezoneOffsetForLocation
          });
          regularValue = `<div>${openStatus}</div>`;
        }