fix: timezone issues

This commit is contained in:
Safwan Samsudeen 2024-04-30 17:43:01 +05:30
parent b29076afed
commit af0276c152
3 changed files with 22 additions and 7 deletions

16
dist/frappe-gantt.js vendored
View File

@ -491,12 +491,18 @@ class O {
this.gantt.gantt_start,
e * this.gantt.options.step,
"hour"
), i = t.getWidth() / this.gantt.options.column_width, r = h.add(
), i = this.gantt.gantt_start.getTimezoneOffset() - s.getTimezoneOffset();
i && (s = h.add(
s,
i * this.gantt.options.step,
i,
"minute"
));
const r = t.getWidth() / this.gantt.options.column_width, o = h.add(
s,
r * this.gantt.options.step,
"hour"
);
return { new_start_date: s, new_end_date: r };
return { new_start_date: s, new_end_date: o };
}
compute_progress() {
const t = this.$bar_progress.getWidth() / this.$bar.getWidth() * 100;
@ -723,7 +729,7 @@ class F {
let o = [];
e.dependencies && (o = e.dependencies.split(",").map((a) => a.trim().replaceAll(" ", "_")).filter((a) => a)), e.dependencies = o;
}
return e.id ? typeof e.id == "string" ? e.id = e.id.replaceAll(" ", "_") : e.id = `${e.id}` : e.id = B(e), e;
return e.id ? typeof e.id == "string" ? e.id = e.id.replaceAll(" ", "_") : e.id = `${e.id}` : e.id = z(e), e;
}), this.setup_dependencies();
}
setup_dependencies() {
@ -1259,7 +1265,7 @@ class F {
}
}
F.VIEW_MODE = l;
function B(n) {
function z(n) {
return n.name + "_" + Math.random().toString(36).slice(2, 12);
}
export {

File diff suppressed because one or more lines are too long

View File

@ -472,6 +472,15 @@ export default class Bar {
x_in_units * this.gantt.options.step,
'hour',
);
const start_offset = 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.options.column_width;
const new_end_date = date_utils.add(
new_start_date,