I have this code from wallpaper engine on steam which counts down the days hours and minuites until christmas and i was wondering how i would add seconds onto the countdown timer and make it show how days hours minuites and seconds left
this bit isnt important it was just saying my post is mainly code add more text and i didnt know what to add so im just adding this bit to it so i can post this
'use strict';
export var scriptProperties = createScriptProperties()
// The time that the coutdown will end on.
.addText({
name: 'date',
label: 'ui_editor_properties_date',
value: '2021-12-25T00:00:00'
})
// Whether the year should be ignored.
.addCheckbox({
name: 'recurring',
label: 'ui_editor_properties_recurring',
value: true
})
// This text will be shown for non-recurring countdowns after they concluded.
.addCheckbox({
name: 'finalMessage',
label: 'ui_editor_properties_end_message',
value: 'The countdown finished!'
})
.finish();
/**
* @param {String} value (for property 'text')
*/
var originalText;
export function update(value) {
var currentDate = new Date();
var targetDate = new Date(scriptProperties.date);
var isRecurringEachYear = scriptProperties.recurring;
if (isRecurringEachYear) {
targetDate.setUTCFullYear(currentDate.getUTCFullYear());
if ((targetDate.getTime() - currentDate.getTime()) < 0) {
targetDate.setUTCFullYear(currentDate.getUTCFullYear() + 1);
}
}
var diff = targetDate.getTime() - currentDate.getTime();
if (!isRecurringEachYear
&& diff < 0) {
return scriptProperties.finalMessage;
}
var years = Math.floor(diff / (1000 * 60 * 60 * 24 * 365));
var days = Math.floor(diff / (1000 * 60 * 60 * 24));
var hours = Math.floor(diff / (1000 * 60 * 60)) % 24;
var minutes = Math.floor(diff / (1000 * 60)) % 60;
if (!isRecurringEachYear) {
days %= 365;
}
value = originalText + '\n';
if (years > 0 && !isRecurringEachYear) {
value += years + ' years, ';
}
if (days > 0) {
value += days + ' days, ';
}
value += hours + ' hours';
if (days == 0) {
value += ', ' + minutes + ' minutes';
}
return value;
}
/**
* @param {String} value (for property 'text')
*/
export function init(value) {
originalText = value;
return value;
}