Using Date and Times with Task Handlers and Trees
Usage
# Sets Scheduled Start Date to 10 minutes from now # Sets Scheduled End Date to 10 days from now @start_date = Time.now + 10 @end_date = Time.now + (86400*10) @field_values['Scheduled Start Date'] = @start_date.iso8601 @field_values['Scheduled End Date'] = @end_date.iso8601 @entry.update_attributes!( :field_values => @field_values )
Example
Here is a sample of the formatted output of various Date fields.
Parameter value to make a date go into a date/time field in Remedy:
<%=@answers['datetime']%>
Format in node: 2011-09-08T20:33:00Z
Remedy Date Field (epoch value) - <%=@dataset['Last Modified Date']%>
Format in node: Thu Sep 08 15:33:53 -0500 2011
Remedy Date Field (epoch value) with iso8601 - <%=@dataset['Last Modified Date'].iso8601%>
Format in node: 2011-09-08T15:33:53-05:00
Parameter value to make a date go into a date field in Remedy:
<%= date = (Time.parse(@answers['Start Date'] + "T00:00:00Z")) date.utc.strftime("%Y-%m-%dT% H:%M:%SZ")%>
Note you can put T06:00:00Z if you want it to be midnight eastern (to be sure it is the correct day) and so on for each time zone.
Here is a sample error message for the Remedy Date Field without the iso8601:
CAUSE: ArsModels::Exceptions::ModelException: MessageType: 2 MessageNum: 1590 MessageText: Format of date or time value is not recognized. AppendedText: "Thu Sep 08 15:33:53 -0500 2011": Date/Time Field
Parameter value to make a date/time human readable to go into a text field/email (this particular format would yield a date like 03/21/2016 9:37 AM:
<%= date = (Time.parse(@answers['Start Date'])) date.utc.strftime("%m/%d/%Y %l:%M %p")%>