Created
July 13, 2022 17:46
-
-
Save cmcdevitt/849ec0ad3c666268ba320a6c77a1dfad to your computer and use it in GitHub Desktop.
Check and Set Date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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