Skip to content

Commit f3fbb16

Browse files
prateekj117iamareebjamal
authored andcommitted
fix: Send event startsAt and endsAt time in event timezone (#3633)
* fix: Send event startsAt and endsAt time in event timezone * Handle cases for other models * Remove duplication
1 parent be64f4e commit f3fbb16

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

app/utils/computed-helpers.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,23 @@ export const computedSegmentedLink = function(property) {
4747
export const computedDateTimeSplit = function(property, segmentFormat, endProperty) {
4848
return computed(property, {
4949
get() {
50-
return moment(this.get(property)).format(getFormat(segmentFormat));
50+
let momentDate = moment(this.get(property));
51+
if (this.constructor.modelName === 'event') {
52+
momentDate = momentDate.tz(this.timezone);
53+
}
54+
return momentDate.format(getFormat(segmentFormat));
5155
},
5256
set(key, value) {
53-
const newDate = moment(value, getFormat(segmentFormat));
57+
let newDate = moment(value, getFormat(segmentFormat));
58+
if (this.constructor.modelName === 'event') {
59+
newDate = newDate.tz(this.timezone, true);
60+
}
5461
let oldDate = newDate;
5562
if (this.get(property)) {
5663
oldDate = moment(this.get(property), segmentFormat === 'date' ? FORM_DATE_FORMAT : FORM_TIME_FORMAT);
64+
if (this.constructor.modelName === 'event') {
65+
oldDate = oldDate.tz(this.timezone, true);
66+
}
5767
} else {
5868
oldDate = newDate;
5969
}

0 commit comments

Comments
 (0)