Skip to content

Commit c6ea187

Browse files
tbowmoThomas Bowman Mørch
andauthored
Fix initial startup issue with missing start / stop times (#38)
* Fix initial startup issue with missing start / stop times * Update package.json --------- Co-authored-by: Thomas Bowman Mørch <thomas.git@bowmo.dk>
1 parent e8b00d1 commit c6ea187

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"author": {
44
"name": "Thomas Bowman Mørch"
55
},
6-
"version": "0.17.0",
6+
"version": "0.18.0",
77
"engines": {
88
"node": ">=14.0.0"
99
},

src/nodes/small-timer.html

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,28 @@ <h3>References</h3>
483483
generateTimes('#node-input-startTime', sunCalcTimes, false)
484484
generateTimes('#node-input-endTime', sunCalcTimes, true)
485485
})
486+
.fail(() => {
487+
const sunCalcTimes = [
488+
{"id":"5101","label":"Sunrise"},
489+
{"id":"5102","label":"Sunrise end"},
490+
{"id":"5103","label":"Golden hour end"},
491+
{"id":"5104","label":"Solar noon"},
492+
{"id":"5105","label":"Golden hour"},
493+
{"id":"5106","label":"Sunset start"},
494+
{"id":"5107","label":"Sunset"},
495+
{"id":"5108","label":"Dusk"},
496+
{"id":"5109","label":"Nautical dusk"},
497+
{"id":"5110","label":"Night"},
498+
{"id":"5111","label":"Nadir"},
499+
{"id":"5112","label":"Night end"},
500+
{"id":"5113","label":"Nautical dawn"},
501+
{"id":"5114","label":"Dawn"},
502+
{"id":"5115","label":"Moonrise"},
503+
{"id":"5116","label":"Moonset"}
504+
]
505+
generateTimes('#node-input-startTime', sunCalcTimes, false)
506+
generateTimes('#node-input-endTime', sunCalcTimes, true)
507+
})
486508

487509
offsetEnable($('#node-input-startTime').val(), '#node-input-startOffset')
488510
offsetEnable($('#node-input-endTime').val(), '#node-input-endOffset')
@@ -565,11 +587,15 @@ <h3>References</h3>
565587
`
566588
let sunCalc = ''
567589
for (const item of sunMoon) {
568-
const time = new Date(item.date)
569-
const hour = leadingZero(time.getHours())
570-
const minute = leadingZero(time.getMinutes())
571-
const tString = `${hour}:${minute}`
572-
sunCalc += `<option value="${item.id}">${tString} - ${item.label}</option>`
590+
if (item.date) {
591+
const time = new Date(item.date)
592+
const hour = leadingZero(time.getHours())
593+
const minute = leadingZero(time.getMinutes())
594+
const tString = `${hour}:${minute}`
595+
sunCalc += `<option value="${item.id}">${tString} - ${item.label}</option>`
596+
} else {
597+
sunCalc += `<option value="${item.id}">${item.label}</option>`
598+
}
573599
}
574600

575601
html += `

0 commit comments

Comments
 (0)