Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
add #1012
Browse files Browse the repository at this point in the history
  • Loading branch information
cutls committed Nov 4, 2023
1 parent 9971617 commit 5881946
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
21 changes: 13 additions & 8 deletions app/js/tl/date.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//日付パーサー
export type IDateType = 'relative' | 'unix' | 'full' | 'absolute' | 'medium' | 'double' | 'unix'
const dateTypes = ['relative', 'unix', 'full', 'absolute', 'medium', 'double', 'unix']
export const isDateType = (item: string): item is IDateType => dateTypes.includes(item)
const dateTypes = ['relative', 'unix', 'full', 'absolute', 'absolute12', 'medium', 'double', 'unix'] as const
export type IDateType = typeof dateTypes[number]
export const isDateType = (item: any): item is IDateType => dateTypes.includes(item)
export function date(str: string, datetype: IDateType) {
if (datetype === 'relative') {
return `<time class="timeago" datetime="${str}"></time>`
Expand All @@ -15,26 +15,31 @@ export function date(str: string, datetype: IDateType) {
const month = date.getMonth() + 1
const min = date.getMinutes().toString().padStart(2, '0')
const sec = date.getSeconds().toString().padStart(2, '0')
const hourRaw = date.getHours()
const isPm = hourRaw >= 12
const inPmStr = isPm ? hourRaw - 12 : hourRaw
const is12 = datetype === 'absolute12'
const hour = is12 ? `${isPm ? 'PM' : 'AM'} ${inPmStr === 0 ? 12 : inPmStr}` : hourRaw
let ret: string
if (datetype === 'full') {
ret = `${date.getFullYear()}/${month}/${date.getDate()} ${date.getHours()}:${min}:${sec}`
ret = `${date.getFullYear()}/${month}/${date.getDate()} ${hour}:${min}:${sec}`
}
if (date.getFullYear() === now.getFullYear()) {
if (date.getMonth() === now.getMonth()) {
if (date.getDate() === now.getDate()) {
if (datetype === 'medium') {
ret = `<time class="timeago" datetime="${str}"></time>`
} else {
ret = `${date.getHours()}:${min}:${sec}`
ret = `${hour}:${min}:${sec}`
}
} else {
ret = `${month}/${date.getDate()} ${date.getHours()}:${min}:${sec}`
ret = `${month}/${date.getDate()} ${hour}:${min}:${sec}`
}
} else {
ret = `${month}/${date.getDate()} ${date.getHours()}:${min}:${sec}`
ret = `${month}/${date.getDate()} ${hour}:${min}:${sec}`
}
} else {
ret = `${date.getFullYear()}/${month}/${date.getDate()} ${date.getHours()}:${min}:${sec}`
ret = `${date.getFullYear()}/${month}/${date.getDate()} ${hour}:${min}:${sec}`
}
if (datetype === 'double') {
return `<time class="timeago" datetime="${str}"></time>/${ret}`
Expand Down
2 changes: 1 addition & 1 deletion app/js/tl/tl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export function tlCloser() {
for (const domain of Object.keys(baseStreaming)) {
for (const userId of Object.keys(baseStreaming[domain])) {
if (globalThis.mastodonBaseWs[domain][userId]) {
globalThis.mastodonBaseWs[acctId][userId].close()
globalThis.mastodonBaseWs[domain][userId].close()
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/view/make/language/en/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"mixtime": "Mixed format: toots posted today are relative-format; others are absolute-format.",
"relativesel": "Relative",
"absolutesel": "Absolute",
"absolute12sel": "Absolute(AM/PM)",
"doublesel": "Both relative and absolute",
"mixsel": "Mixed",
"locale": "Server's unique locale time",
Expand Down
1 change: 1 addition & 0 deletions app/view/make/language/ja-KS/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"mixtime": "混合表示は、当日のトゥートのみ相対、それ以外は絶対で表示 ",
"relativesel": "相対時間",
"absolutesel": "絶対時間",
"absolute12sel": "絶対時間(12時間制)",
"doublesel": "両方表示",
"mixsel": "混合表示",
"locale": "独自ロケールを使用",
Expand Down
1 change: 1 addition & 0 deletions app/view/make/language/ja/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"mixtime": "混合表示は、当日のトゥートのみ相対、それ以外は絶対で表示 ",
"relativesel": "相対時間",
"absolutesel": "絶対時間",
"absolute12sel": "絶対時間(12時間制)",
"doublesel": "両方表示",
"mixsel": "混合表示",
"locale": "独自ロケールを使用",
Expand Down
4 changes: 4 additions & 0 deletions app/view/make/setting.sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ export const tlConstruction = [
text: '@@absolutesel@@',
value: 'absolute'
},
{
text: '@@absolute12sel@@',
value: 'absolute12'
},
{
text: '@@doublesel@@',
value: 'double'
Expand Down

0 comments on commit 5881946

Please sign in to comment.