Browse Source

Notate high/low, hide low precip %

Only show every other hour horizontally.
fix-precip
Kevin Mok 3 years ago
parent
commit
c2f187cfdf
Signed by: Kevin-Mok GPG Key ID: AEA75288DC135CF5
  1. 20
      dark-sky.js
  2. 2
      dark-sky.service
  3. 3
      dark-sky.timer

20
dark-sky.js

@ -52,13 +52,18 @@ const logWeatherJson = (jsonFile, loc) => {
const hoursList = ['H']
const tempsList = ['°C']
const precipList = ['%P']
for (let i = 0; i < 9; i++) {
for (let i = 0; i < 16; i += 2) {
const hourInfo = weatherInfo['hourly']['data'][i]
const date = new Date(hourInfo['time'] * 1000)
hoursList.push(date.getHours())
tempsList.push(Math.floor(hourInfo['apparentTemperature']))
precipList.push(Math.floor(hourInfo['precipProbability']))
const precipProbability = Math.floor(hourInfo['precipProbability'])
precipList.push((precipProbability < 20) ? '' : precipProbability)
}
const maxTempIndex = tempsList.indexOf(Math.max(...tempsList.slice(1)))
const minTempIndex = tempsList.indexOf(Math.min(...tempsList.slice(1)))
tempsList[maxTempIndex] = `${tempsList[maxTempIndex]}+`
tempsList[minTempIndex] = `${tempsList[minTempIndex]}-`
log(table([hoursList, tempsList, precipList], TABLE_CONFIG));
}
resolve()
@ -66,10 +71,15 @@ const logWeatherJson = (jsonFile, loc) => {
})
}
const formatTimeUnit = unit => { return ((unit < 10) ? '0' : '') + unit }
logTablePromises = [
logWeatherJson('./toronto.json', 'Toronto'),
logWeatherJson('./markham.json', 'Markham'),
logWeatherJson('./toronto.json', 'Toronto')]
]
Promise.all(logTablePromises).then(results => {
const now = new Date()
log(`${CREDIT_MSG}\n\nLast updated: ${now.getHours()}:${now.getMinutes()}`)
// const now = new Date()
// const lastUpdatedTime = `${formatTimeUnit(now.getHours())}:${formatTimeUnit(now.getMinutes())}`
// log(`${CREDIT_MSG}\n\nLast updated: ${lastUpdatedTime}`)
log(CREDIT_MSG)
})

2
dark-sky.service

@ -3,7 +3,7 @@ Description=Fetch local weather
[Service]
Type=oneshot
ExecStart=/home/kevin/weather/dark-sky.fish
ExecStart=/home/kevin/weather/dark-sky.sh
User=kevin
Group=kevin
Environment=PATH=/usr/bin:/usr/local/bin

3
dark-sky.timer

@ -2,7 +2,8 @@
Description=Fetch local weather
[Timer]
OnCalendar=6,12,18,00:00
# OnCalendar=6,12,18,00:00
OnCalendar=*:0
Persistent=true
[Install]

Loading…
Cancel
Save