[NEW] User preference for 24- or 12-hour clock (#11169)
Closes #2922 Closes #4706 This PR adds a personal preference for what timestamp format to use:  **Default** uses the timestamp formats (usually `LT` and `LLL`) defined in admin settings. **12-hour** uses a 12-hour format (`6:30 PM` or `January 3, 2018 6:30 PM`) **24-hour** uses a 24-hour format (`18:30` or `January 3, 2018 18:30`)pull/11866/merge
parent
be7386f60a
commit
9a77976e40
@ -0,0 +1,24 @@ |
||||
import moment from 'moment'; |
||||
export const formatTime = (time) => { |
||||
switch (RocketChat.getUserPreference(Meteor.userId(), 'clockMode', false)) { |
||||
case 1: |
||||
return moment(time).format('h:mm A'); |
||||
case 2: |
||||
return moment(time).format('H:mm'); |
||||
default: |
||||
return moment(time).format(RocketChat.settings.get('Message_TimeFormat')); |
||||
} |
||||
}; |
||||
|
||||
export const formatDateAndTime = (time) => { |
||||
switch (RocketChat.getUserPreference(Meteor.userId(), 'clockMode', false)) { |
||||
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(RocketChat.settings.get('Message_TimeAndDateFormat')); |
||||
} |
||||
}; |
||||
|
||||
export const formatDate = (time) => moment(time).format(RocketChat.settings.get('Message_DateFormat')); |
Loading…
Reference in new issue