Merge pull request #3787 from thelounge/xpaw/12h

Add an option to display 12h times
This commit is contained in:
Pavel Djundik 2020-03-09 10:36:07 +02:00 committed by GitHub
commit e47e54b934
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 12 deletions

View File

@ -5,7 +5,8 @@
:class="{ :class="{
'hide-motd': !$store.state.settings.motd, 'hide-motd': !$store.state.settings.motd,
'colored-nicks': $store.state.settings.coloredNicks, 'colored-nicks': $store.state.settings.coloredNicks,
'show-seconds': $store.state.settings.showSeconds, 'time-seconds': $store.state.settings.showSeconds,
'time-12h': $store.state.settings.use12hClock,
}" }"
> >
<div <div

View File

@ -100,12 +100,19 @@ export default {
isPreviousSource: Boolean, isPreviousSource: Boolean,
}, },
computed: { computed: {
messageTime() { timeFormat() {
const format = this.$store.state.settings.showSeconds let format;
? constants.timeFormats.msgWithSeconds
: constants.timeFormats.msgDefault;
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() { messageTimeLocale() {
return localetime(this.message.time); return localetime(this.message.time);

View File

@ -88,6 +88,16 @@
Show seconds in timestamp Show seconds in timestamp
</label> </label>
</div> </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"> <div v-if="!$store.state.serverConfiguration.public && $store.state.settings.advanced">
<h2>Automatic away message</h2> <h2>Automatic away message</h2>

View File

@ -1309,12 +1309,18 @@ textarea.input {
padding-left: 10px; padding-left: 10px;
width: 55px; width: 55px;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
box-sizing: content-box; /* highlights have a border-left */
} }
#chat.show-seconds .time { #chat.time-12h .time,
#chat.time-seconds .time {
width: 75px; width: 75px;
} }
#chat.time-seconds.time-12h .time {
width: 90px;
}
#chat .from { #chat .from {
padding-right: 10px; padding-right: 10px;
text-align: right; text-align: right;
@ -1500,14 +1506,9 @@ textarea.input {
#chat .chat-view[data-type="channel"] .msg.highlight .time { #chat .chat-view[data-type="channel"] .msg.highlight .time {
padding-left: 5px; padding-left: 5px;
width: 50px;
color: #696969; color: #696969;
} }
#chat.show-seconds .chat-view[data-type="channel"] .msg.highlight .time {
width: 70px;
}
#chat .chat-view[data-type="channel"] .msg.highlight .content { #chat .chat-view[data-type="channel"] .msg.highlight .content {
border-left: 1px solid var(--highlight-bg-color); border-left: 1px solid var(--highlight-bg-color);
} }

View File

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

View File

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