Scheduler - Show user local time, but schedule as UTC??
We are running 12.7 SP8 with a plan to upgrade to 14.0 SP3 in the near term. I know that v14 has TimeZone support for Scheduler but I don't want to force the upgrade just for this feature.
When our users open the Scheduler, I want to show them their local time but I want the Scheduler to convert that time to UTC for scheduling (since our back-end server all run UTC).
When the user clicks on the Scheduler, I am passing the ScheduleXml value as a Link Parameter with the following value:
<Schedule Type="Once" StartDate="@Date.Today~" FirstRunTime="@Function.Time~" />
This shows them their local time in the Scheduler Popup, but then when they submit the Schedule, it is subtracting 4 hours for UTC, so they are expecting the Schedule to run 'Now', but it doesn't run because the server says it was supposed to run 4 hours ago.
If I pass the ScheduleXml with Function.TimeUtc, the users see what they think is 'Now + 4 hours' which is correct on the server but confusing to the user.
We have Moment.js loaded, so I am attempting to manipulate the HIDDEN time so that the user gets Function.Time but the HIDDEN converts to UTC with the following JS code (TaskSchedule is the ID of our Schedule Element):
var curTime = moment.utc(document.getElementById('datSchStartDate_TaskSchedule').value+' '+document.getElementById('selSchFirstRunTime_TaskSchedule').value,'MM/DD/YYYY hh:mm a');
var offset = moment().utcOffset();
var newTime = curTime.utcOffset(-offset).format("hh:mm a");
document.getElementById('selSchFirstRunTime_TaskSchedule_Hidden').value = newTime;
I'm still testing to see if manipulating the back-end, Hidden value will work to get this the way that I need it, but I'm curious if anyone has done anything like this or has an alternate solution.
I'll update this thread once I get this code pushed to our Dev server for testing.
-
Not tested at all, but what if you hide Logi's "selSchFirstRunTime_rdSchedule" input for time and inject a new input which allows the user to select their local time. Upon entry it would programmatically update Logi's "selSchFirstRunTime_rdSchedule" input with the UTC time.
0 -
Thanks VISUI
I'm testing out a few other options, but I just got feedback indicating that we won't release Scheduling until after our 14.0 SP3 update. This will allow me to use Info's new Timezone support feature. We have an internal table where I grab the user's TimeZone value as a Session Token, so I'm planning to do the following:
- Use our TMF to hide the Timezone option:
<!-- Hide TimeZone -->
<SetAttribute ID="rowSchTimezone_rdSchId" Class="ThemeHidden" /> - Push my team to allow the default of Daily at 9:00 am for the default since running Once Right Now is not a very common use case for Scheduling Bookmarks. If they disagree, then I'll have to work out some JS to pass the FirstRunTime as the user's current local time. The JS I was using stopped working for some reason; I believe there is a timing issue where the Hidden Input isn't 'ready' when the ScheduleXml is created. I was using
varLocal = moment().format("HH:mm");
document.getElementById('hdnLocalTime').value = varLocal;Then setting the ScheduleXml's FirstRunTime to @Request.hdnLocalTime~
Not currently working as I'd like. - Add our @Session.UserTZ~ value (e.g. "Eastern Standard Time") in the ScheduleXml Link Parameters for TimezoneID:
<Schedule Type="Daily" StartDate="@Date.Today~" FirstRunTime="09:00" TimezoneID="@Session.UserTZ~"/>
- I'm also using TimePicker.js to ensure proper Time formatting of the input, running the following onload under a transparent 1px img:
$('#selSchFirstRunTime_TaskSchedule').timepicker({
timeFormat: 'h:mm p',
minTime: '12:00 AM',
maxTime: '11:59 PM',
dropdown: false
});
Hopefully, my team approves the 9am Daily (or maybe 9am Monday??) and I don't have to keep fiddling with the values. :)
0 - Use our TMF to hide the Timezone option:
Please sign in to leave a comment.
Comments
2 comments