Fixing 24 hour forecast
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import {existsSync, mkdirSync, writeFileSync} from 'fs';
|
||||
import * as path from 'node:path';
|
||||
import {resolve, dirname} from 'path';
|
||||
import {fileURLToPath} from 'url';
|
||||
import * as path from 'node:path';
|
||||
|
||||
const DIR = resolve(dirname(fileURLToPath(import.meta.url)), '../data/icons');
|
||||
|
||||
@@ -18,28 +18,3 @@ export async function fetchIcon(icon) {
|
||||
await downloadIcon(icon, iconPath);
|
||||
return iconPath;
|
||||
}
|
||||
|
||||
export function getWeatherCondition(data) {
|
||||
// Determine primary condition
|
||||
if(data.lightning_rate > 0 && data.raining === 'True') {
|
||||
return {label: 'Thunderstorm', code: 211, icon: '11d'};
|
||||
}
|
||||
|
||||
if(data.raining === 'True') {
|
||||
if(data.precipitation > 7.6) return {label: 'Heavy Rain', code: 502, icon: '10d'};
|
||||
if(data.precipitation > 2.5) return {label: 'Moderate Rain', code: 501, icon: '10d'};
|
||||
return {label: 'Light Rain', code: 500, icon: '09d'};
|
||||
}
|
||||
|
||||
if(data.visibility < 10) {
|
||||
return {label: 'Mist', code: 701, icon: '50d'};
|
||||
}
|
||||
|
||||
const dayNight = data.daytime ? 'd' : 'n';
|
||||
if(data.clouds > 85) return {label: 'Overcast Clouds', code: 804, icon: `04${dayNight}`};
|
||||
if(data.clouds > 50) return {label: 'Broken Clouds', code: 803, icon: `04${dayNight}`};
|
||||
if(data.clouds > 25) return {label: 'Scattered Clouds', code: 802, icon: `03${dayNight}`};
|
||||
if(data.clouds > 10) return {label: 'Few Clouds', code: 801, icon: `02${dayNight}`};
|
||||
|
||||
return {label: 'Clear Sky', code: 800, icon: `01${dayNight}`};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user