Skip to content

Instantly share code, notes, and snippets.

@jngnyc
Last active April 12, 2018 14:39
Show Gist options
  • Save jngnyc/ebef88a5fae61992dcc165b564aa6f03 to your computer and use it in GitHub Desktop.
Save jngnyc/ebef88a5fae61992dcc165b564aa6f03 to your computer and use it in GitHub Desktop.
window.WebhookUtils = {
upperCase: function (val) {
if (val) {
val = val.toUpperCase();
}
return val;
},
// Lowercase transformation:
lowerCase: function (val) {
if (val) {
val = val.toLowerCase();
}
return val;
},
// convert timestamp in UNIX time format to human-readable format
unixTimeToHumanReadable: function (val) {
var date = val;
// Hours part from the timestamp
var hours = date.getHours();
// Minutes part from the timestamp
var minutes = "0" + date.getMinutes();
// Seconds part from the timestamp
var seconds = "0" + date.getSeconds();
// Will display time in 10:30:23 format
var formattedTime = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
return formattedTime;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment