The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/lib/utils/formatDateAndTime.ts

20 lines
754 B

import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import moment, { MomentInput } from 'moment';
import { settings } from '../../../app/settings/client';
import { getUserPreference } from '../../../app/utils/lib/getUserPreference';
export const formatDateAndTime = (time: MomentInput): string => {
const clockMode = Tracker.nonreactive(() => getUserPreference(Meteor.userId(), 'clockMode', false));
const messageTimeAndDateFormat = Tracker.nonreactive(() => settings.get('Message_TimeAndDateFormat'));
switch (clockMode) {
case 1:
return moment(time).format('MMMM D, Y h:mm A');
case 2:
return moment(time).format('MMMM D, Y H:mm');
default:
return moment(time).format(messageTimeAndDateFormat);
}
};