Skip to content

Commit

Permalink
tz moment
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Jun 14, 2022
1 parent 3b3ad25 commit 70f9fd5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import moment from 'moment';
import { tz } from 'moment-timezone';
import type { ILivechatBusinessHour, ILivechatDepartment } from '@rocket.chat/core-typings';

import { IWorkHoursCronJobsWrapper, LivechatBusinessHoursRaw } from '../../../models/server/raw/LivechatBusinessHours';
Expand Down Expand Up @@ -71,8 +72,8 @@ export abstract class AbstractBusinessHourType {

private convertWorkHours(businessHourData: ILivechatBusinessHour): ILivechatBusinessHour {
businessHourData.workHours.forEach((hour: any) => {
const startUtc = moment.tz(`${hour.day}:${hour.start}`, 'dddd:HH:mm', businessHourData.timezone.name).utc();
const finishUtc = moment.tz(`${hour.day}:${hour.finish}`, 'dddd:HH:mm', businessHourData.timezone.name).utc();
const startUtc = tz(`${hour.day}:${hour.start}`, 'dddd:HH:mm', businessHourData.timezone.name).utc();
const finishUtc = tz(`${hour.day}:${hour.finish}`, 'dddd:HH:mm', businessHourData.timezone.name).utc();
hour.start = {
time: hour.start,
utc: {
Expand Down Expand Up @@ -103,7 +104,7 @@ export abstract class AbstractBusinessHourType {
if (!timezone) {
return String(moment().utcOffset() / 60);
}
return moment.tz(timezone).format('Z');
return tz(timezone).format('Z');
}

private formatDayOfTheWeekFromServerTimezoneAndUtcHour(utc: any, format: string): string {
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/livechat/server/business-hour/Default.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import moment from 'moment';
import { tz } from 'moment-timezone';
import { ILivechatBusinessHour, LivechatBusinessHourTypes } from '@rocket.chat/core-typings';

import { AbstractBusinessHourType, IBusinessHourType } from './AbstractBusinessHour';
Expand All @@ -21,7 +21,7 @@ export class DefaultBusinessHour extends AbstractBusinessHourType implements IBu
return businessHourData;
}
businessHourData.timezone = {
name: timezoneName || moment.tz.guess(),
name: timezoneName || tz.guess(),
utc: this.getUTCFromTimezone(timezoneName),
};
await this.baseSaveBusinessHour(businessHourData);
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/livechat/server/lib/Analytics.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
import moment from 'moment';
import moment from 'moment-timezone';

import { LivechatRooms } from '../../../models';
import { LivechatRooms as LivechatRoomsRaw } from '../../../models/server/raw';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Meteor } from 'meteor/meteor';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
import _ from 'underscore';
import moment from 'moment';
import moment from 'moment-timezone';

import { settings } from '../../../settings';
import { Rooms, Messages, Users } from '../../../models/server';
import { SmarshHistory } from '../../../models/server/raw';
import { MessageTypes } from '../../../ui-utils';
import { smarsh } from '../lib/rocketchat';
import 'moment-timezone';

const start =
'<table style="width: 100%; border: 1px solid; border-collapse: collapse; table-layout: fixed; margin-top: 10px; font-size: 12px; word-break: break-word;"><tbody>';
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/app/smarsh-connector/server/settings.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import moment from 'moment';
import moment from 'moment-timezone';

import { settingsRegistry } from '../../settings/server';
import 'moment-timezone';

settingsRegistry.addGroup('Smarsh', function addSettings() {
this.add('Smarsh_Enabled', false, {
Expand Down

0 comments on commit 70f9fd5

Please sign in to comment.