diff --git a/RemoteTK.component b/RemoteTK.component index 071114a..71ba2bc 100644 --- a/RemoteTK.component +++ b/RemoteTK.component @@ -196,6 +196,26 @@ if (remotetk.Client === undefined) { escape: false }); } + + /* + * + * Helper function to ensure dates are properly formatted when using RemoteTK + * Per Apex docs: the specified string should use the standard date format “yyyy-MM-dd HH:mm:ss” in the local time zone. + */ + remotetk.Client.prototype.formatDateTime = function(jsDateObject) { + var output = jsDateObject.getFullYear() + '-'; + if(jsDateObject.getMonth() + 1 < 10) output += '0'; + output += jsDateObject.getMonth() + 1 + '-'; + if(jsDateObject.getDate() < 10) output += '0'; + output += jsDateObject.getDate() + ' '; + if(jsDateObject.getHours() < 10) output += '0'; + output += jsDateObject.getHours() + ':'; + if(jsDateObject.getMinutes() < 10) output += '0'; + output += jsDateObject.getMinutes() + ':'; + if(jsDateObject.getSeconds() < 10) output += '0'; + output += jsDateObject.getSeconds(); + return output; + } } - \ No newline at end of file + diff --git a/RemoteTKController.cls b/RemoteTKController.cls index 859cd3a..71665b8 100644 --- a/RemoteTKController.cls +++ b/RemoteTKController.cls @@ -64,6 +64,9 @@ public class RemoteTKController { if (valueType == Schema.DisplayType.Date) { obj.put(key, Date.valueOf(svalue)); + } else if (valueType == Schema.DisplayType.DateTime) { + // per apex docs: the specified string should use the standard date format “yyyy-MM-dd HH:mm:ss” in the local time zone. + obj.put(key, DateTime.valueOf(svalue)); } else if (valueType == Schema.DisplayType.Percent || valueType == Schema.DisplayType.Currency) { obj.put(key, svalue == '' ? null : Decimal.valueOf(svalue)); @@ -291,4 +294,4 @@ public class RemoteTKController { return JSON.serialize(result); } -} \ No newline at end of file +}