Merge pull request 'feat: improved local time display' (#9851) from naskya/calckey:localtime-improvement into develop
Reviewed-on: https://codeberg.org/calckey/calckey/pulls/9851
This commit is contained in:
commit
64a737d001
@ -1426,7 +1426,7 @@ _profile:
|
||||
metadataContent: "Content"
|
||||
changeAvatar: "Change avatar"
|
||||
changeBanner: "Change banner"
|
||||
locationDescription: "If you enter your city, it will display your local time to other users."
|
||||
locationDescription: "If you enter your city first, it will display your local time to other users."
|
||||
_exportOrImport:
|
||||
allNotes: "All posts"
|
||||
followingList: "Followed users"
|
||||
|
@ -1423,7 +1423,7 @@ _profile:
|
||||
metadataContent: "内容"
|
||||
changeAvatar: "アバター画像を変更"
|
||||
changeBanner: "バナー画像を変更"
|
||||
locationDescription: "正しく入力すると、あなたの現地時間が他のユーザーに表示されます。"
|
||||
locationDescription: "英語表記の都市名から始まる内容を入力すると、現地時間がユーザーページに表示されます。"
|
||||
_exportOrImport:
|
||||
allNotes: "全ての投稿"
|
||||
followingList: "フォロー"
|
||||
|
@ -353,11 +353,31 @@ const age = $computed(() => {
|
||||
});
|
||||
|
||||
const timeForThem = $computed(() => {
|
||||
const tzInfo = cityTimezones.lookupViaCity(
|
||||
props.user.location!.replace(/\s.*/, "")
|
||||
);
|
||||
if (tzInfo.length == 0) return "";
|
||||
const maybeCityNames = [
|
||||
props.user.location!,
|
||||
props.user
|
||||
.location!.replace(
|
||||
/[^A-Za-z0-9ÁĆÉǴÍḰĹḾŃÓṔŔŚÚÝŹáćéǵíḱĺḿńóṕŕśúýź\-\'\.\s].*/,
|
||||
""
|
||||
)
|
||||
.trim(),
|
||||
props.user.location!.replace(
|
||||
/[^A-Za-zÁĆÉǴÍḰĹḾŃÓṔŔŚÚÝŹáćéǵíḱĺḿńóṕŕśúýź\-\'\.].*/,
|
||||
""
|
||||
),
|
||||
props.user.location!.replace(
|
||||
/[^A-Za-zÁĆÉǴÍḰĹḾŃÓṔŔŚÚÝŹáćéǵíḱĺḿńóṕŕśúýź].*/,
|
||||
""
|
||||
),
|
||||
];
|
||||
|
||||
for (const city of maybeCityNames) {
|
||||
let tzInfo = cityTimezones.lookupViaCity(city);
|
||||
if (tzInfo.length == 0) continue;
|
||||
|
||||
const tz = tzInfo[0].timezone;
|
||||
if (!tz) continue;
|
||||
|
||||
const theirTime = new Date().toLocaleString("en-US", {
|
||||
timeZone: tz,
|
||||
hour12: false,
|
||||
@ -365,6 +385,9 @@ const timeForThem = $computed(() => {
|
||||
return ` (${theirTime.split(",")[1].trim().split(":")[0]}:${theirTime
|
||||
.split(" ")[1]
|
||||
.slice(-5, -3)})`;
|
||||
}
|
||||
|
||||
return "";
|
||||
});
|
||||
|
||||
function menu(ev) {
|
||||
|
Loading…
Reference in New Issue
Block a user