Skip to content

Instantly share code, notes, and snippets.

@cmcdevitt
Created July 13, 2022 17:46
Show Gist options
  • Select an option

  • Save cmcdevitt/849ec0ad3c666268ba320a6c77a1dfad to your computer and use it in GitHub Desktop.

Select an option

Save cmcdevitt/849ec0ad3c666268ba320a6c77a1dfad to your computer and use it in GitHub Desktop.
Check and Set Date
checkDateFormat: function(date) {
//A very simple regex to see if the incoming data is compatable with the SN Date field
var answer = false;
var regexps = /[0-9]{4}-[0-9]{2}-[0-9]{2}/; // example 2022-02-28
if (regexps.test(date)) {
answer = true;
}
return answer;
}
//Test and Set Dates
var detection_time = source.u_detection_time;
var resolved_time = source.u_resolved_time.toString();
if (util.checkDateFormat(detection_time)) {
target.first_found = detection_time;
}
if (util.checkDateFormat(resolved_time)) {
target.closed_at = new GlideDateTime(resolved_time + ' 12:00:01');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment