diff --git a/apps/common/main/lib/controller/Comments.js b/apps/common/main/lib/controller/Comments.js index 4eb3dead9..3eb2c10e7 100644 --- a/apps/common/main/lib/controller/Comments.js +++ b/apps/common/main/lib/controller/Comments.js @@ -177,6 +177,7 @@ define([ comment.asc_putText(commentVal); comment.asc_putTime(this.utcDateToString(new Date())); + comment.asc_putOnlyOfficeTime(this.ooDateToString(new Date())); comment.asc_putUserId(this.currentUserId); comment.asc_putUserName(this.currentUserName); comment.asc_putSolved(false); @@ -212,6 +213,7 @@ define([ ascComment.asc_putText(comment.get('comment')); ascComment.asc_putQuoteText(comment.get('quote')); ascComment.asc_putTime(t.utcDateToString(new Date(comment.get('time')))); + ascComment.asc_putOnlyOfficeTime(t.ooDateToString(new Date(comment.get('time')))); ascComment.asc_putUserId(comment.get('userid')); ascComment.asc_putUserName(comment.get('username')); ascComment.asc_putSolved(!comment.get('resolved')); @@ -227,6 +229,7 @@ define([ if (addReply) { addReply.asc_putText(reply.get('reply')); addReply.asc_putTime(t.utcDateToString(new Date(reply.get('time')))); + addReply.asc_putOnlyOfficeTime(t.ooDateToString(new Date(reply.get('time')))); addReply.asc_putUserId(reply.get('userid')); addReply.asc_putUserName(reply.get('username')); @@ -300,6 +303,7 @@ define([ ascComment.asc_putText(commentVal); ascComment.asc_putQuoteText(comment.get('quote')); ascComment.asc_putTime(t.utcDateToString(new Date(comment.get('time')))); + ascComment.asc_putOnlyOfficeTime(t.ooDateToString(new Date(comment.get('time')))); ascComment.asc_putUserId(t.currentUserId); ascComment.asc_putUserName(t.currentUserName); ascComment.asc_putSolved(comment.get('resolved')); @@ -326,6 +330,7 @@ define([ if (addReply) { addReply.asc_putText(reply.get('reply')); addReply.asc_putTime(t.utcDateToString(new Date(reply.get('time')))); + addReply.asc_putOnlyOfficeTime(t.ooDateToString(new Date(reply.get('time')))); addReply.asc_putUserId(reply.get('userid')); addReply.asc_putUserName(reply.get('username')); @@ -354,6 +359,7 @@ define([ ascComment.asc_putText(comment.get('comment')); ascComment.asc_putQuoteText(comment.get('quote')); ascComment.asc_putTime(me.utcDateToString(new Date(comment.get('time')))); + ascComment.asc_putOnlyOfficeTime(me.ooDateToString(new Date(comment.get('time')))); ascComment.asc_putUserId(comment.get('userid')); ascComment.asc_putUserName(comment.get('username')); ascComment.asc_putSolved(comment.get('resolved')); @@ -379,6 +385,7 @@ define([ } addReply.asc_putTime(me.utcDateToString(new Date(reply.get('time')))); + addReply.asc_putOnlyOfficeTime(me.ooDateToString(new Date(reply.get('time')))); ascComment.asc_addReply(addReply); } @@ -414,6 +421,7 @@ define([ ascComment.asc_putText(comment.get('comment')); ascComment.asc_putQuoteText(comment.get('quote')); ascComment.asc_putTime(me.utcDateToString(new Date(comment.get('time')))); + ascComment.asc_putOnlyOfficeTime(me.ooDateToString(new Date(comment.get('time')))); ascComment.asc_putUserId(comment.get('userid')); ascComment.asc_putUserName(comment.get('username')); ascComment.asc_putSolved(comment.get('resolved')); @@ -430,6 +438,7 @@ define([ if (addReply) { addReply.asc_putText(reply.get('reply')); addReply.asc_putTime(me.utcDateToString(new Date(reply.get('time')))); + addReply.asc_putOnlyOfficeTime(me.ooDateToString(new Date(reply.get('time')))); addReply.asc_putUserId(reply.get('userid')); addReply.asc_putUserName(reply.get('username')); @@ -442,6 +451,7 @@ define([ if (addReply) { addReply.asc_putText(replyVal); addReply.asc_putTime(me.utcDateToString(new Date())); + addReply.asc_putOnlyOfficeTime(me.ooDateToString(new Date())); addReply.asc_putUserId(me.currentUserId); addReply.asc_putUserName(me.currentUserName); @@ -468,6 +478,7 @@ define([ ascComment.asc_putText(comment.get('comment')); ascComment.asc_putQuoteText(comment.get('quote')); ascComment.asc_putTime(me.utcDateToString(new Date(comment.get('time')))); + ascComment.asc_putOnlyOfficeTime(me.ooDateToString(new Date(comment.get('time')))); ascComment.asc_putUserId(comment.get('userid')); ascComment.asc_putUserName(comment.get('username')); ascComment.asc_putSolved(comment.get('resolved')); @@ -484,6 +495,7 @@ define([ if (addReply) { addReply.asc_putText(reply.get('reply')); addReply.asc_putTime(me.utcDateToString(new Date(reply.get('time')))); + addReply.asc_putOnlyOfficeTime(me.ooDateToString(new Date(reply.get('time')))); addReply.asc_putUserId(reply.get('userid')); addReply.asc_putUserName(reply.get('username')); @@ -666,8 +678,8 @@ define([ if (comment) { t = this; - date = (data.asc_getTime() == '') ? - new Date() : new Date(this.stringUtcToLocalDate(data.asc_getTime())); + date = (data.asc_getOnlyOfficeTime()) ? new Date(this.stringOOToLocalDate(data.asc_getOnlyOfficeTime())) : + ((data.asc_getTime() == '') ? new Date() : new Date(this.stringUtcToLocalDate(data.asc_getTime()))); comment.set('comment', data.asc_getText()); comment.set('userid', data.asc_getUserId()); @@ -684,8 +696,8 @@ define([ repliesCount = data.asc_getRepliesCount(); for (i = 0; i < repliesCount; ++i) { - dateReply = (data.asc_getReply(i).asc_getTime() == '') ? - new Date() : new Date(this.stringUtcToLocalDate(data.asc_getReply(i).asc_getTime())); + dateReply = (data.asc_getReply(i).asc_getOnlyOfficeTime()) ? new Date(this.stringOOToLocalDate(data.asc_getReply(i).asc_getOnlyOfficeTime())) : + ((data.asc_getReply(i).asc_getTime() == '') ? new Date() : new Date(this.stringUtcToLocalDate(data.asc_getReply(i).asc_getTime()))); replies.push(new Common.Models.Reply({ id : Common.UI.getId(), @@ -1030,7 +1042,8 @@ define([ // helpers readSDKComment: function (id, data) { - var date = (data.asc_getTime() == '') ? new Date() : new Date(this.stringUtcToLocalDate(data.asc_getTime())); + var date = (data.asc_getOnlyOfficeTime()) ? new Date(this.stringOOToLocalDate(data.asc_getOnlyOfficeTime())) : + ((data.asc_getTime() == '') ? new Date() : new Date(this.stringUtcToLocalDate(data.asc_getTime()))); var comment = new Common.Models.Comment({ uid : id, userid : data.asc_getUserId(), @@ -1067,8 +1080,8 @@ define([ var repliesCount = data.asc_getRepliesCount(); if (repliesCount) { for (i = 0; i < repliesCount; ++i) { - date = (data.asc_getReply(i).asc_getTime() == '') ? - new Date() : new Date(this.stringUtcToLocalDate(data.asc_getReply(i).asc_getTime())); + date = (data.asc_getReply(i).asc_getOnlyOfficeTime()) ? new Date(this.stringOOToLocalDate(data.asc_getReply(i).asc_getOnlyOfficeTime())) : + ((data.asc_getReply(i).asc_getTime() == '') ? new Date() : new Date(this.stringUtcToLocalDate(data.asc_getReply(i).asc_getTime()))); replies.push(new Common.Models.Reply({ id : Common.UI.getId(), @@ -1169,6 +1182,7 @@ define([ } comment.asc_putText(commentVal); comment.asc_putTime(this.utcDateToString(new Date())); + comment.asc_putOnlyOfficeTime(this.ooDateToString(new Date())); comment.asc_putUserId(this.currentUserId); comment.asc_putUserName(this.currentUserName); comment.asc_putSolved(false); @@ -1275,6 +1289,19 @@ define([ timeZoneOffsetInMs: (new Date()).getTimezoneOffset() * 60000, + stringOOToLocalDate: function (date) { + if (typeof date === 'string') + return parseInt(date); + + return 0; + }, + ooDateToString: function (date) { + if (Object.prototype.toString.call(date) === '[object Date]') + return (date.getTime()).toString(); + + return ''; + }, + stringUtcToLocalDate: function (date) { if (typeof date === 'string') return parseInt(date) + this.timeZoneOffsetInMs;