improve city search
This commit is contained in:
parent
9501e8a882
commit
afa8f06ef6
1 changed files with 22 additions and 12 deletions
|
@ -353,10 +353,17 @@ const age = $computed(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const timeForThem = $computed(() => {
|
const timeForThem = $computed(() => {
|
||||||
const tzInfo = cityTimezones.lookupViaCity(
|
const maybeCityNames = [
|
||||||
props.user.location!.replace(/\s.*/, "")
|
props.user.location!,
|
||||||
);
|
props.user.location!.replace(/[^A-Za-z].*/, ""),
|
||||||
if (tzInfo.length == 0) return "";
|
props.user.location!.replace(/[^A-Za-z\-\'\.].*/, ""),
|
||||||
|
props.user.location!.replace(/[^A-Za-z0-9\-\'\.\s].*/, ""),
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const city of maybeCityNames) {
|
||||||
|
let tzInfo = cityTimezones.lookupViaCity(city);
|
||||||
|
if (tzInfo.length == 0) continue;
|
||||||
|
|
||||||
const tz = tzInfo[0].timezone;
|
const tz = tzInfo[0].timezone;
|
||||||
const theirTime = new Date().toLocaleString("en-US", {
|
const theirTime = new Date().toLocaleString("en-US", {
|
||||||
timeZone: tz,
|
timeZone: tz,
|
||||||
|
@ -365,6 +372,9 @@ const timeForThem = $computed(() => {
|
||||||
return ` (${theirTime.split(",")[1].trim().split(":")[0]}:${theirTime
|
return ` (${theirTime.split(",")[1].trim().split(":")[0]}:${theirTime
|
||||||
.split(" ")[1]
|
.split(" ")[1]
|
||||||
.slice(-5, -3)})`;
|
.slice(-5, -3)})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
});
|
});
|
||||||
|
|
||||||
function menu(ev) {
|
function menu(ev) {
|
||||||
|
|
Loading…
Reference in a new issue