fix: dates broken in dst

This commit is contained in:
Safwan Samsudeen 2024-12-17 12:37:25 +02:00
parent 097d69ce90
commit d5ee5a4e45
2 changed files with 5 additions and 12 deletions

View File

@ -485,17 +485,7 @@ export default class Bar {
x_in_units * this.gantt.config.step, x_in_units * this.gantt.config.step,
this.gantt.config.unit, this.gantt.config.unit,
); );
const start_offset = console.log(date_utils.diff(new_start_date, this.gantt.gantt_start));
this.gantt.gantt_start.getTimezoneOffset() -
new_start_date.getTimezoneOffset();
if (start_offset) {
new_start_date = date_utils.add(
new_start_date,
start_offset,
'minute',
);
}
const width_in_units = bar.getWidth() / this.gantt.config.column_width; const width_in_units = bar.getWidth() / this.gantt.config.column_width;
const new_end_date = date_utils.add( const new_end_date = date_utils.add(

View File

@ -125,7 +125,10 @@ export default {
diff(date_a, date_b, scale = 'day') { diff(date_a, date_b, scale = 'day') {
let milliseconds, seconds, hours, minutes, days, months, years; let milliseconds, seconds, hours, minutes, days, months, years;
milliseconds = date_a - date_b; milliseconds =
date_a -
date_b +
(date_b.getTimezoneOffset() - date_a.getTimezoneOffset()) * 60000;
seconds = milliseconds / 1000; seconds = milliseconds / 1000;
minutes = seconds / 60; minutes = seconds / 60;
hours = minutes / 60; hours = minutes / 60;