fix: use exact local time string for justification dates to prevent postgres timezone shift bugs
This commit is contained in:
parent
b850d76ba5
commit
bc9f012129
|
|
@ -0,0 +1,25 @@
|
|||
const { Pool } = require('pg');
|
||||
const pool = new Pool({
|
||||
user: 'postgres',
|
||||
host: 'localhost',
|
||||
database: 'edumanager',
|
||||
password: 'admin',
|
||||
port: 5432,
|
||||
});
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const res = await pool.query("SELECT id, aluno_id, data, tipo, justificativa, justificativa_aceita FROM frequencias WHERE justificativa IS NOT NULL LIMIT 5;");
|
||||
console.log(JSON.stringify(res.rows, null, 2));
|
||||
|
||||
// Check all attendance for a student with justification
|
||||
const res2 = await pool.query("SELECT * FROM frequencias WHERE aluno_id = (SELECT aluno_id FROM frequencias WHERE justificativa IS NOT NULL LIMIT 1) ORDER BY data DESC LIMIT 5");
|
||||
console.log("Student Recent:", JSON.stringify(res2.rows, null, 2));
|
||||
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
pool.end();
|
||||
}
|
||||
}
|
||||
run();
|
||||
|
|
@ -611,9 +611,7 @@ export default function Frequencia() {
|
|||
) : canJustify ? (
|
||||
<button
|
||||
onClick={() => {
|
||||
const lMs = parseLessonDateTime(lesson.date, lesson.startTime || '00:00:00');
|
||||
if (isNaN(lMs)) return;
|
||||
const timestamp = new Date(lMs).toISOString();
|
||||
const timestamp = `${lesson.date}T${lesson.startTime || '00:00'}:00`;
|
||||
openJustifyModal(timestamp);
|
||||
}}
|
||||
style={{
|
||||
|
|
@ -719,9 +717,7 @@ export default function Frequencia() {
|
|||
return (isNaN(msB) ? 0 : msB) - (isNaN(msA) ? 0 : msA);
|
||||
})
|
||||
.map(l => {
|
||||
const lMs = parseLessonDateTime(l.date, l.startTime || '00:00:00');
|
||||
if (isNaN(lMs)) return null;
|
||||
const ts = new Date(lMs).toISOString();
|
||||
const ts = `${l.date}T${l.startTime || '00:00'}:00`;
|
||||
return (
|
||||
<option key={l.id} value={ts}>
|
||||
{formatDateFull(l.date)}{l.startTime ? ` — ${l.startTime.substring(0, 5)}` : ''}{l.endTime ? ` às ${l.endTime.substring(0, 5)}` : ''}
|
||||
|
|
|
|||
Loading…
Reference in New Issue