misc: gpt did a goofy
This commit is contained in:
1 parent
3c239ce21c
commit
66eca58d01
3 files changed
+10
-12
No files matched your search
@@ -9,6 +9,7 @@ function buildUrl(inputUrl: URL): URL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function handleError({ error, event }) {
|
export function handleError({ error, event }) {
|
||||||
|
console.error(error)
|
||||||
return {
|
return {
|
||||||
message: 'There was an error during rendering',
|
message: 'There was an error during rendering',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,11 +141,13 @@
|
|||||||
<span class="mx-4 text-xs opacity-80 text-left my-2">Post Actions</span>
|
<span class="mx-4 text-xs opacity-80 text-left my-2">Post Actions</span>
|
||||||
<MenuButton
|
<MenuButton
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
navigator.clipboard.writeText(
|
if (typeof navigator != 'undefined') {
|
||||||
`${$page.url.origin}/post/${
|
navigator.clipboard.writeText(
|
||||||
$authData?.instance ?? DEFAULT_INSTANCE_URL
|
`${$page.url.origin}/post/${
|
||||||
}/${postRes.post.id}`
|
$authData?.instance ?? DEFAULT_INSTANCE_URL
|
||||||
)
|
}/${postRes.post.id}`
|
||||||
|
)
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon src={Square2Stack} width={16} mini />
|
<Icon src={Square2Stack} width={16} mini />
|
||||||
|
|||||||
@@ -4,10 +4,8 @@
|
|||||||
function formatRelativeDate(date: Date) {
|
function formatRelativeDate(date: Date) {
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
|
|
||||||
// Calculate the difference in milliseconds between 'now' and 'date'
|
|
||||||
const diffInMillis = now - date.getTime()
|
const diffInMillis = now - date.getTime()
|
||||||
|
|
||||||
// Define time thresholds for different units (milliseconds)
|
|
||||||
const thresholds = [
|
const thresholds = [
|
||||||
{ unit: 'second', threshold: 1000 },
|
{ unit: 'second', threshold: 1000 },
|
||||||
{ unit: 'minute', threshold: 60 * 1000 },
|
{ unit: 'minute', threshold: 60 * 1000 },
|
||||||
@@ -16,16 +14,13 @@
|
|||||||
{ unit: 'week', threshold: 7 * 24 * 60 * 60 * 1000 },
|
{ unit: 'week', threshold: 7 * 24 * 60 * 60 * 1000 },
|
||||||
{ unit: 'month', threshold: 30 * 24 * 60 * 60 * 1000 },
|
{ unit: 'month', threshold: 30 * 24 * 60 * 60 * 1000 },
|
||||||
{ unit: 'year', threshold: 365 * 24 * 60 * 60 * 1000 },
|
{ unit: 'year', threshold: 365 * 24 * 60 * 60 * 1000 },
|
||||||
// You can add more units as needed, e.g., week, month, year
|
|
||||||
]
|
]
|
||||||
|
|
||||||
// Iterate through the thresholds to find the appropriate unit to display
|
|
||||||
for (let i = thresholds.length - 1; i >= 0; i--) {
|
for (let i = thresholds.length - 1; i >= 0; i--) {
|
||||||
if (diffInMillis >= thresholds[i].threshold) {
|
if (diffInMillis >= thresholds[i].threshold) {
|
||||||
const value = Math.round(diffInMillis / thresholds[i].threshold)
|
const value = Math.round(diffInMillis / thresholds[i].threshold)
|
||||||
|
|
||||||
// Create a RelativeTimeFormat instance with user's locale and options
|
const rtf = new Intl.RelativeTimeFormat('en', {
|
||||||
const rtf = new Intl.RelativeTimeFormat(navigator.language, {
|
|
||||||
numeric: 'always',
|
numeric: 'always',
|
||||||
style: 'long',
|
style: 'long',
|
||||||
})
|
})
|
||||||
@@ -34,7 +29,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'Now' // If none of the above conditions match defaulting to "Now"
|
return 'Now'
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user