Add an option to display 12h times

This commit is contained in:
Pavel Djundik 2020-02-29 11:37:45 +02:00
parent 6f04216af5
commit 3630ab8519
4 changed files with 27 additions and 5 deletions

View File

@ -100,12 +100,19 @@ export default {
isPreviousSource: Boolean,
},
computed: {
messageTime() {
const format = this.$store.state.settings.showSeconds
? constants.timeFormats.msgWithSeconds
: constants.timeFormats.msgDefault;
timeFormat() {
let format;
return dayjs(this.message.time).format(format);
if (this.$store.state.settings.use12hClock) {
format = this.$store.state.settings.showSeconds ? "msg12hWithSeconds" : "msg12h";
} else {
format = this.$store.state.settings.showSeconds ? "msgWithSeconds" : "msgDefault";
}
return constants.timeFormats[format];
},
messageTime() {
return dayjs(this.message.time).format(this.timeFormat);
},
messageTimeLocale() {
return localetime(this.message.time);

View File

@ -88,6 +88,16 @@
Show seconds in timestamp
</label>
</div>
<div>
<label class="opt">
<input
:checked="$store.state.settings.use12hClock"
type="checkbox"
name="use12hClock"
/>
Show 12-hour timestamps
</label>
</div>
<div v-if="!$store.state.serverConfiguration.public && $store.state.settings.advanced">
<h2>Automatic away message</h2>

View File

@ -24,6 +24,8 @@ const condensedTypes = new Set(["chghost", "join", "part", "quit", "nick", "kick
const timeFormats = {
msgDefault: "HH:mm",
msgWithSeconds: "HH:mm:ss",
msg12h: "hh:mm A",
msg12hWithSeconds: "hh:mm:ss A",
};
// This file is required by server, can't use es6 export

View File

@ -64,6 +64,9 @@ export const config = normalizeConfig({
showSeconds: {
default: false,
},
use12hClock: {
default: false,
},
statusMessages: {
default: "condensed",
},