diff --git a/eltiempo/index.html b/eltiempo/index.html index 3419e41..f9bb81f 100644 --- a/eltiempo/index.html +++ b/eltiempo/index.html @@ -3,6 +3,7 @@ Estadísticas | El Tiempo + diff --git a/eltiempo/js/estadisticas.js b/eltiempo/js/estadisticas.js index 5ca1632..6c68589 100644 --- a/eltiempo/js/estadisticas.js +++ b/eltiempo/js/estadisticas.js @@ -21,7 +21,11 @@ function buildApiUrl({ ciudad, fecha = null, desde = null, hasta = null }) { if (desde) params.append("desde", desde); if (hasta) params.append("hasta", hasta); + console.log("24 - Construyendo URL con parámetros:", { ciudad, fecha, desde, hasta }); + console.log("URL API:", `${BASE_API}?${params.toString()}`); + return `${BASE_API}?${params.toString()}`; + } // ==================== @@ -135,6 +139,8 @@ function renderMonthStats(data) { function renderTrend(data) { const byYear = {}; + console.log("Datos recibidos para tendencia histórica:", data); + // Agrupar datos por año para el mes seleccionado data.forEach(d => { const date = new Date(d.dia); @@ -149,6 +155,8 @@ function renderTrend(data) { const container = $("trend-container"); + console.log("Datos agrupados por año para tendencia:", byYear); + if (Object.keys(byYear).length === 0) { container.innerHTML = "

No hay datos históricos para este mes.

"; return; @@ -179,12 +187,34 @@ function renderTrend(data) { // Cargar mes actual según selectedMonth // ==================== function loadCurrentMonth() { - const year = new Date().getFullYear(); + const ahora = new Date(); + const currentYear = ahora.getFullYear(); + const currentMonth = ahora.getMonth(); + + // 1. Calculamos el año objetivo (si selectedMonth es mayor al actual, asumimos año anterior o lógica de negocio) + // Para simplificar tu oposición, usaremos el año actual. + const year = currentYear; const month = selectedMonth + 1; - const firstDay = `${year}-${String(month).padStart(2,"0")}-01`; - const lastDay = new Date(year, month, 0).toISOString().split("T")[0]; + // 2. Primer día del mes + const firstDay = `${year}-${String(month).padStart(2, "0")}-01`; + // 3. Cálculo del último día (evitando el desfase de toISOString) + let ultimoDiaObj = new Date(year, month, 0); + + // LÓGICA DE SEGURIDAD: Si es el mes/año actual, el último día es HOY, no el fin de mes. + if (selectedMonth === currentMonth && year === currentYear) { + ultimoDiaObj = ahora; + } + + // Formateo manual para evitar el error de -1 día por zona horaria (UTC) + const y = ultimoDiaObj.getFullYear(); + const m = String(ultimoDiaObj.getMonth() + 1).padStart(2, "0"); + const d = String(ultimoDiaObj.getDate()).padStart(2, "0"); + const lastDay = `${y}-${m}-${d}`; + + console.log("Cargando datos para:", monthNames[selectedMonth], `(${firstDay} a ${lastDay})`); + loadStats({ desde: firstDay, hasta: lastDay }); } diff --git a/eltiempo/servidor/api-weather-fechas.php b/eltiempo/servidor/api-weather-fechas.php index 1e60bd1..6a205b1 100644 --- a/eltiempo/servidor/api-weather-fechas.php +++ b/eltiempo/servidor/api-weather-fechas.php @@ -114,6 +114,8 @@ $sql .= " ORDER BY DATE(fecha); "; +console_log("SQL: $sql"); +console_log("Params: " . implode(", ", $params)); // ============================ // 6. PREPARAR Y EJECUTAR // ============================ diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..bd0e80b Binary files /dev/null and b/favicon.ico differ diff --git a/img/foto-perfil copy.png b/img/foto-perfil copy.png deleted file mode 100644 index 87ff949..0000000 Binary files a/img/foto-perfil copy.png and /dev/null differ diff --git a/img/tatianalogo.png b/img/tatianalogo.png new file mode 100644 index 0000000..aca09cb Binary files /dev/null and b/img/tatianalogo.png differ diff --git a/index.html b/index.html index 44ae2bf..62c0cfc 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ Tatiana Villa - Sobre mí - +