{"id":21986,"date":"2025-10-31T08:12:00","date_gmt":"2025-10-31T07:12:00","guid":{"rendered":"https:\/\/nachhaltiger24.ch\/?page_id=21986"},"modified":"2025-10-31T08:12:02","modified_gmt":"2025-10-31T07:12:02","slug":"wetter","status":"publish","type":"page","link":"https:\/\/nachhaltiger24.ch\/en\/wetter\/","title":{"rendered":"Wetter"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Wie ist und wird das Wetter in der <a href=\"https:\/\/nachhaltiger24.ch\/en\/die-sichersten-laender-in-krisenzeiten-schweiz-auf-platz-1\/\">Schweiz<\/a> in den n\u00e4chsten Tagen<\/p>\n\n\n\n<!-- Nachhaltiger24 Wetter-Widget (Open-Meteo, schl\u00fcsselfrei) -->\n<div class=\"nh24-weather\" data-city=\"Bern\" data-days=\"5\" data-units=\"metric\"><\/div>\n\n<style>\n.nh24-weather{ --bg:#0b1320; --card:#111a2b; --text:#e8eef9; --muted:#a9b4c9; --acc:#33d17a;\n  font-family:system-ui,Segoe UI,Roboto,Arial,sans-serif; color:var(--text);\n  background:linear-gradient(180deg,#0b1320 0%,#0e162a 100%); border-radius:16px; padding:14px;\n  box-shadow:0 10px 30px rgba(0,0,0,.35); max-width:900px; margin:0 auto; line-height:1.5;\n}\n.nh24w-head{display:flex;gap:12px;align-items:center;justify-content:space-between;margin-bottom:10px}\n.nh24w-title{font-weight:800;font-size:18px;letter-spacing:.2px}\n.nh24w-sub{color:var(--muted);font-size:12px}\n.nh24w-grid{display:grid;grid-template-columns:repeat(5,minmax(120px,1fr));gap:10px}\n@media(max-width:720px){.nh24w-grid{grid-template-columns:repeat(3,1fr)}}\n@media(max-width:460px){.nh24w-grid{grid-template-columns:repeat(2,1fr)}}\n.nh24w-item{background:var(--card);border:1px solid #1f2b45;border-radius:12px;padding:10px}\n.nh24w-day{font-weight:700;margin-bottom:6px}\n.nh24w-row{display:flex;align-items:center;justify-content:space-between;margin:4px 0}\n.nh24w-ico{font-size:22px;margin-right:6px}\n.nh24w-temp{font-weight:800}\n.nh24w-badge{background:#0f213d;border:1px solid #223055;border-radius:999px;padding:4px 8px;font-size:12px;color:var(--muted)}\n.nh24w-footer{display:flex;justify-content:space-between;align-items:center;margin-top:10px;color:var(--muted);font-size:11px}\n.nh24w-spinner{display:inline-block;width:16px;height:16px;border:2px solid #294064;border-top-color:var(--acc);border-radius:50%;animation:spin .8s linear infinite;margin-left:8px}\n@keyframes spin{to{transform:rotate(360deg)}}\n<\/style>\n\n<script>\n(function(){\n  const fallback = {\n    \"bern\":           {name:\"Bern\",           latitude:46.94809, longitude:7.44744,  timezone:\"Europe\/Zurich\", country_code:\"CH\"},\n    \"muri bei bern\":  {name:\"Muri bei Bern\",  latitude:46.925,    longitude:7.499,    timezone:\"Europe\/Zurich\", country_code:\"CH\"},\n    \"z\u00fcrich\":         {name:\"Z\u00fcrich\",         latitude:47.3769,   longitude:8.5417,   timezone:\"Europe\/Zurich\", country_code:\"CH\"},\n    \"zurich\":         {name:\"Z\u00fcrich\",         latitude:47.3769,   longitude:8.5417,   timezone:\"Europe\/Zurich\", country_code:\"CH\"},\n    \"basel\":          {name:\"Basel\",          latitude:47.5596,   longitude:7.5886,   timezone:\"Europe\/Zurich\", country_code:\"CH\"},\n    \"genf\":           {name:\"Genf\",           latitude:46.2044,   longitude:6.1432,   timezone:\"Europe\/Zurich\", country_code:\"CH\"},\n    \"geneva\":         {name:\"Genf\",           latitude:46.2044,   longitude:6.1432,   timezone:\"Europe\/Zurich\", country_code:\"CH\"},\n    \"lausanne\":       {name:\"Lausanne\",       latitude:46.5197,   longitude:6.6323,   timezone:\"Europe\/Zurich\", country_code:\"CH\"},\n    \"luzern\":         {name:\"Luzern\",         latitude:47.0502,   longitude:8.3093,   timezone:\"Europe\/Zurich\", country_code:\"CH\"},\n    \"st. gallen\":     {name:\"St. Gallen\",     latitude:47.4245,   longitude:9.3767,   timezone:\"Europe\/Zurich\", country_code:\"CH\"},\n    \"lugano\":         {name:\"Lugano\",         latitude:46.0037,   longitude:8.9511,   timezone:\"Europe\/Zurich\", country_code:\"CH\"},\n    \"chur\":           {name:\"Chur\",           latitude:46.8508,   longitude:9.5329,   timezone:\"Europe\/Zurich\", country_code:\"CH\"},\n    \"interlaken\":     {name:\"Interlaken\",     latitude:46.6863,   longitude:7.8632,   timezone:\"Europe\/Zurich\", country_code:\"CH\"}\n  };\n  const mapIcon=(code,day=true)=>{\n    const sun = day ? \"\u2600\ufe0f\" : \"????\";\n    if([0].includes(code)) return sun;\n    if([1,2].includes(code)) return day ? \"????\ufe0f\" : \"\u2601\ufe0f\";\n    if([3].includes(code)) return \"\u2601\ufe0f\";\n    if([45,48].includes(code)) return \"????\ufe0f\";\n    if([51,53,55,56,57].includes(code)) return \"????\ufe0f\";\n    if([61,63,65,80,81,82].includes(code)) return \"????\ufe0f\";\n    if([66,67].includes(code)) return \"????\ufe0f\";\n    if([71,73,75,77,85,86].includes(code)) return \"\u2744\ufe0f\";\n    if([95,96,99].includes(code)) return \"\u26c8\ufe0f\";\n    return \"????\ufe0f\";\n  };\n  const fmtDay = (iso, locale='de-CH')=>{\n    const d=new Date(iso);\n    return d.toLocaleDateString(locale,{weekday:'short', day:'2-digit', month:'2-digit'});\n  };\n  const widgets = document.querySelectorAll('.nh24-weather');\n\n  widgets.forEach(async el=>{\n    const cityAttr = (el.getAttribute('data-city')||'Bern').trim();\n    const key = cityAttr.toLowerCase();\n    const days = Math.min(Math.max(parseInt(el.getAttribute('data-days')||'5',10),1),7);\n    const units = (el.getAttribute('data-units') || 'metric').toLowerCase();\n    const useUS = units==='imperial';\n    const unitTemp = useUS ? '\u00b0F' : '\u00b0C'; const unitRain = useUS ? 'in' : 'mm';\n\n    el.innerHTML = `\n      <div class=\"nh24w-head\">\n        <div>\n          <div class=\"nh24w-title\">Wetter \u2013 ${cityAttr}<\/div>\n          <div class=\"nh24w-sub\">Vorhersage (n\u00e4chste ${days} Tage) <span class=\"nh24w-spinner\"><\/span><\/div>\n        <\/div>\n        <div class=\"nh24w-badge\">Open-Meteo<\/div>\n      <\/div>\n      <div class=\"nh24w-grid\"><\/div>\n      <div class=\"nh24w-footer\">\n        <span>Aktualisiert: <span class=\"nh24w-upd\">\u2014<\/span><\/span>\n        <span><\/span>\n      <\/div>\n    `;\n\n    try{\n      \/\/ 1) Direkte Koordinaten bevorzugen, wenn gesetzt\n      let lat = parseFloat(el.getAttribute('data-lat'));\n      let lon = parseFloat(el.getAttribute('data-lon'));\n      let place = cityAttr, tz = 'auto', cc='CH';\n\n      \/\/ 2) Fallback-Tabelle\n      if(!(isFinite(lat) && isFinite(lon))){\n        if(fallback[key]){\n          ({latitude:lat, longitude:lon, name:place, timezone:tz, country_code:cc} = fallback[key]);\n        }\n      }\n\n      \/\/ 3) Open-Meteo Geocoding, falls noch keine Koordinaten\n      if(!(isFinite(lat) && isFinite(lon))){\n        const queries = [cityAttr, cityAttr+', Schweiz', cityAttr+', Switzerland', key];\n        let hit=null;\n        for(const q of queries){\n          const geoUrl = 'https:\/\/geocoding-api.open-meteo.com\/v1\/search?count=1&language=de&format=json&name='+encodeURIComponent(q);\n          const res = await fetch(geoUrl).then(r=>r.json());\n          if(res && res.results && res.results.length){\n            hit = res.results[0]; break;\n          }\n        }\n        if(!hit) throw new Error('Ort nicht gefunden: '+cityAttr);\n        lat = hit.latitude; lon = hit.longitude; place = hit.name || cityAttr; tz = hit.timezone || 'auto'; cc=hit.country_code||'';\n      }\n\n      \/\/ Forecast\n      const p = new URLSearchParams({\n        latitude: String(lat),\n        longitude: String(lon),\n        daily: 'weathercode,temperature_2m_max,temperature_2m_min,precipitation_sum',\n        timezone: tz || 'auto',\n        forecast_days: String(days)\n      });\n      const fc = await fetch('https:\/\/api.open-meteo.com\/v1\/forecast?'+p.toString()).then(r=>r.json());\n      const grid = el.querySelector('.nh24w-grid');\n      const upd  = el.querySelector('.nh24w-upd');\n\n      const tMax = fc.daily.temperature_2m_max;\n      const tMin = fc.daily.temperature_2m_min;\n      const wCodes = fc.daily.weathercode;\n      const rain = fc.daily.precipitation_sum;\n      const dates = fc.daily.time;\n\n      const toF = c => (c*9\/5)+32;\n      const toIn = mm => (mm\/25.4);\n\n      grid.innerHTML = dates.map((d,i)=>{\n        const max = useUS ? Math.round(toF(tMax[i])) : Math.round(tMax[i]);\n        const min = useUS ? Math.round(toF(tMin[i])) : Math.round(tMin[i]);\n        const pr  = useUS ? toIn(rain[i]||0).toFixed(2) : Math.round(rain[i]||0);\n        const ico = mapIcon(wCodes[i], true);\n        return `\n          <div class=\"nh24w-item\">\n            <div class=\"nh24w-day\">${fmtDay(d)}<\/div>\n            <div class=\"nh24w-row\"><span class=\"nh24w-ico\">${ico}<\/span><span>Wettercode ${wCodes[i]}<\/span><\/div>\n            <div class=\"nh24w-row\"><span>Max<\/span><span class=\"nh24w-temp\">${max}${unitTemp}<\/span><\/div>\n            <div class=\"nh24w-row\"><span>Min<\/span><span>${min}${unitTemp}<\/span><\/div>\n            <div class=\"nh24w-row\"><span>Niederschlag<\/span><span>${pr} ${unitRain}<\/span><\/div>\n          <\/div>\n        `;\n      }).join('');\n\n      upd.textContent = new Date().toLocaleString('de-CH');\n      el.querySelector('.nh24w-title').textContent = `Wetter \u2013 ${place}${cc? ', '+cc:''}`;\n      el.querySelector('.nh24w-sub').textContent = `Vorhersage (n\u00e4chste ${days} Tage)`;\n    }catch(err){\n      el.innerHTML = `<div style=\"padding:14px;background:#2a1b1b;color:#ffdada;border:1px solid #6b2a2a;border-radius:12px\">\n        <strong>Wetter konnte nicht geladen werden.<\/strong><br>${(err&&err.message)||'Unbekannter Fehler'}\n      <\/div>`;\n      console.error(err);\n    }\n  });\n})();\n<\/script>\n\n","protected":false},"excerpt":{"rendered":"<p>Wie ist und wird das Wetter in der Schweiz in den n\u00e4chsten Tagen<\/p>","protected":false},"author":67,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-21986","page","type-page","status-publish"],"_links":{"self":[{"href":"https:\/\/nachhaltiger24.ch\/en\/wp-json\/wp\/v2\/pages\/21986","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nachhaltiger24.ch\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/nachhaltiger24.ch\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/nachhaltiger24.ch\/en\/wp-json\/wp\/v2\/users\/67"}],"replies":[{"embeddable":true,"href":"https:\/\/nachhaltiger24.ch\/en\/wp-json\/wp\/v2\/comments?post=21986"}],"version-history":[{"count":1,"href":"https:\/\/nachhaltiger24.ch\/en\/wp-json\/wp\/v2\/pages\/21986\/revisions"}],"predecessor-version":[{"id":21987,"href":"https:\/\/nachhaltiger24.ch\/en\/wp-json\/wp\/v2\/pages\/21986\/revisions\/21987"}],"wp:attachment":[{"href":"https:\/\/nachhaltiger24.ch\/en\/wp-json\/wp\/v2\/media?parent=21986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}