Improve weather analysis by comparing same day of week from previous year

Update weather service to calculate the date of the same day of the week from the previous year for more relevant weather pattern analysis.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: d43bd811-9372-45a7-8ac9-4a954c0538e1
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/d43bd811-9372-45a7-8ac9-4a954c0538e1/gqQIolA
This commit is contained in:
michaelschal committed 2025-08-15 08:41:13 +00:00
1 parent 60efc7ef88
commit 5f5da0bc77
3 files changed
+39 -6

No files matched your search

+1 -1
View File
@@ -2,4 +2,4 @@
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
#HttpOnly_localhost FALSE / FALSE 1755333401 connect.sid s%3AjMs5qISzQqgSDWVwymmCwD7sNZeqwqW5.o9F18DbCy7ZfD1L%2BShBKs4vzlzFslz979pQixekMpmg
#HttpOnly_localhost FALSE / FALSE 1755333603 connect.sid s%3AQqa7VC9Kmev2sSuyP6rb67zs4VszjTJP.RwnrDHc4pdPJyIwe93Hg9PTGpAF73AsiSmjdDq4MC4c
+1 -1
View File
@@ -29,7 +29,7 @@ The platform is built with a clear separation of concerns, utilizing a modern fu
- **Data Synchronization:** Logic is implemented to ensure data consistency between development (in-memory storage) and production (PostgreSQL) environments, particularly for order status and relationships.
**Feature Specifications:**
- **Weather Integration:** A comprehensive, modern weather interface displays detailed weather conditions sourced directly from the Visual Crossing API with French language support.
- **Weather Integration:** A comprehensive, modern weather interface displays detailed weather conditions sourced directly from the Visual Crossing API with French language support. Features intelligent date comparison using the same day of the week from the previous year for more relevant weather pattern analysis (e.g., Friday August 15, 2025 vs Friday August 16, 2024).
- **Order and Delivery Management:** Full CRUD operations for orders and deliveries, including linking orders to deliveries and managing their statuses.
- **Reconciliation:** Functionality for reconciling Bills of Lading (BL) and invoices with immediate UI updates.
- **User and Permission Management:** Granular access controls ensuring that users (e.g., employees) have appropriate permissions for tasks like creating customer orders.
+37 -4
View File
@@ -93,12 +93,45 @@ export class WeatherService {
}
/**
* Calcule la date de l'année précédente pour la même date
* Calcule la date de l'année précédente pour le même jour de la semaine
*/
getPreviousYearDate(date: Date = new Date()): string {
const previousYear = new Date(date);
previousYear.setFullYear(date.getFullYear() - 1);
return previousYear.toISOString().split('T')[0]; // Format YYYY-MM-DD
const currentYear = date.getFullYear();
const currentMonth = date.getMonth();
const currentDayOfWeek = date.getDay(); // 0 = dimanche, 1 = lundi, etc.
// Créer une date pour l'année précédente, même mois
const previousYear = new Date(currentYear - 1, currentMonth, 1);
// Trouver le premier jour de la semaine correspondant dans ce mois
const firstDayOfMonth = previousYear.getDay();
const daysToAdd = (currentDayOfWeek - firstDayOfMonth + 7) % 7;
// Calculer quelle semaine nous sommes dans le mois actuel
const currentDate = date.getDate();
const currentWeekOfMonth = Math.ceil(currentDate / 7);
// Aller à la même semaine du mois l'année précédente
const targetDate = new Date(currentYear - 1, currentMonth, 1 + daysToAdd + (currentWeekOfMonth - 1) * 7);
// Si la date calculée dépasse le mois, prendre la dernière occurrence de ce jour dans le mois
if (targetDate.getMonth() !== currentMonth) {
// Revenir en arrière d'une semaine
targetDate.setDate(targetDate.getDate() - 7);
}
console.log(`🗓️ [DATE-CALC] Aujourd'hui: ${date.toISOString().split('T')[0]} (${this.getDayName(currentDayOfWeek)})`);
console.log(`🗓️ [DATE-CALC] Année précédente: ${targetDate.toISOString().split('T')[0]} (${this.getDayName(targetDate.getDay())})`);
return targetDate.toISOString().split('T')[0]; // Format YYYY-MM-DD
}
/**
* Retourne le nom du jour de la semaine
*/
private getDayName(dayOfWeek: number): string {
const days = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'];
return days[dayOfWeek];
}
/**