Added Utils.js, for miscellaneous Javascript functions

pull/2/head
Sander Ferdinand 6 years ago
parent 7fe9d71eb3
commit 75ccc7a31b

@ -0,0 +1,25 @@
/**
* Formats a date.
* @param {date} date - toggle decorations
* @param {params} params -
*/
function formatDate( date, params ) {
var options = {
weekday: "short",
year: "numeric",
month: "long",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
timeZone: "UTC",
timeZoneName: "short",
};
options = [options, params].reduce(function (r, o) {
Object.keys(o).forEach(function (k) { r[k] = o[k]; });
return r;
}, {});
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
return new Date( date ).toLocaleString( 'en-US', options );
}

@ -206,5 +206,7 @@
<file>images/warning.png</file>
<file>images/checkedBlackIcon.png</file>
<file>images/rightArrowInactive.png</file>
<file>js/Windows.js</file>
<file>js/Utils.js</file>
</qresource>
</RCC>