summaryrefslogtreecommitdiffstats
path: root/web/react/utils/utils.jsx
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-10-16 08:22:37 -0400
committerChristopher Speller <crspeller@gmail.com>2015-10-16 08:22:37 -0400
commit89716cb046ee3c8f13b361053d91149f5ce29cbf (patch)
tree1faaf70fe1f51c19fc52b742de705e41edca660c /web/react/utils/utils.jsx
parent6846940abfb56496d3010db11c46998033d4d9f5 (diff)
parent79fcb9808421dd93342a9538d05dd2259f5dd14b (diff)
downloadchat-89716cb046ee3c8f13b361053d91149f5ce29cbf.tar.gz
chat-89716cb046ee3c8f13b361053d91149f5ce29cbf.tar.bz2
chat-89716cb046ee3c8f13b361053d91149f5ce29cbf.zip
Merge pull request #1054 from stasvovk/PLT-637
PLT-638: added display tab under account settings. added 24h time option
Diffstat (limited to 'web/react/utils/utils.jsx')
-rw-r--r--web/react/utils/utils.jsx33
1 files changed, 20 insertions, 13 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 0457d620f..561c2c4c4 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -4,6 +4,7 @@
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
var ChannelStore = require('../stores/channel_store.jsx');
var UserStore = require('../stores/user_store.jsx');
+var PreferenceStore = require('../stores/preference_store.jsx');
var TeamStore = require('../stores/team_store.jsx');
var Constants = require('../utils/constants.jsx');
var ActionTypes = Constants.ActionTypes;
@@ -164,23 +165,29 @@ export function displayDate(ticks) {
}
export function displayTime(ticks) {
- var d = new Date(ticks);
- var hours = d.getHours();
- var minutes = d.getMinutes();
-
- var ampm = 'AM';
- if (hours >= 12) {
- ampm = 'PM';
- }
+ const d = new Date(ticks);
+ let hours = d.getHours();
+ let minutes = d.getMinutes();
+ let ampm = '';
- hours = hours % 12;
- if (!hours) {
- hours = '12';
- }
if (minutes <= 9) {
minutes = '0' + minutes;
}
- return hours + ':' + minutes + ' ' + ampm;
+
+ const useMilitaryTime = PreferenceStore.getPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time', {value: 'false'}).value;
+ if (useMilitaryTime === 'false') {
+ ampm = ' AM';
+ if (hours >= 12) {
+ ampm = ' PM';
+ }
+
+ hours = hours % 12;
+ if (!hours) {
+ hours = '12';
+ }
+ }
+
+ return hours + ':' + minutes + ampm;
}
export function displayDateTime(ticks) {