Initial commit: TimeClock v3 - Node.js/Vue.js Zeiterfassung
Features: - Backend: Node.js/Express mit MySQL/MariaDB - Frontend: Vue.js 3 mit Composition API - UTC-Zeithandling für korrekte Zeiterfassung - Timewish-basierte Überstundenberechnung - Wochenübersicht mit Urlaubs-/Krankheits-/Feiertagshandling - Bereinigtes Arbeitsende (Generell/Woche) - Überstunden-Offset für historische Daten - Fixed Layout mit scrollbarem Content - Kompakte UI mit grünem Theme
This commit is contained in:
69
backend/fix-timezone-correct.js
Normal file
69
backend/fix-timezone-correct.js
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Korrektes Timezone-Fix für Worklog-Einträge
|
||||
*
|
||||
* Situation:
|
||||
* - DB hat DATETIME-Spalten (ohne Timezone-Info)
|
||||
* - Alte App hat lokale Zeit gespeichert: 08:07 → in DB: "2025-10-14 08:07:18"
|
||||
* - Sequelize liest mit timezone='+00:00' und interpretiert als UTC
|
||||
* - Sequelize gibt zurück: "2025-10-14T08:07:18.000Z"
|
||||
* - JavaScript interpretiert das als 08:07 UTC
|
||||
* - JavaScript zeigt: 10:07 lokal (UTC+2 MESZ)
|
||||
*
|
||||
* Was wir wollen:
|
||||
* - DB hat: "2025-10-14 08:07:18" (lokale Zeit)
|
||||
* - Anzeige: "08:07" (lokale Zeit)
|
||||
*
|
||||
* Lösung: NICHTS in der DB ändern!
|
||||
* Stattdessen: UTC-Komponenten direkt als lokale Zeit interpretieren
|
||||
*/
|
||||
|
||||
const mysql = require('mysql2/promise');
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.join(__dirname, '.env') });
|
||||
|
||||
async function checkTimezones() {
|
||||
let connection;
|
||||
|
||||
try {
|
||||
connection = await mysql.createConnection({
|
||||
host: process.env.DB_HOST || 'localhost',
|
||||
user: process.env.DB_USER || 'root',
|
||||
password: process.env.DB_PASSWORD || '',
|
||||
database: process.env.DB_NAME || 'stechuhr2'
|
||||
});
|
||||
|
||||
console.log('✅ Datenbankverbindung hergestellt\n');
|
||||
|
||||
// Hole Beispiel-Einträge vom 14. und 15. Oktober
|
||||
const [rows] = await connection.execute(
|
||||
`SELECT id, tstamp, state
|
||||
FROM worklog
|
||||
WHERE id IN (4153, 4154, 4155, 4156, 4157, 4158, 4159, 4160)
|
||||
ORDER BY id ASC`
|
||||
);
|
||||
|
||||
console.log('📊 Aktuelle DB-Einträge:\n');
|
||||
rows.forEach(row => {
|
||||
const state = JSON.parse(row.tstamp);
|
||||
console.log(`ID ${row.id}: ${row.tstamp} (Rohdaten aus DB)`);
|
||||
});
|
||||
|
||||
console.log('\n💡 Diese Zeiten sollten die LOKALEN Zeiten sein (MEZ/MESZ)');
|
||||
console.log('💡 JavaScript sollte sie direkt so anzeigen, OHNE Timezone-Konvertierung\n');
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Fehler:', error);
|
||||
process.exit(1);
|
||||
} finally {
|
||||
if (connection) {
|
||||
await connection.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkTimezones().then(() => {
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user