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 }) {
|
||||
console.error(error)
|
||||
return {
|
||||
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>
|
||||
<MenuButton
|
||||
on:click={() => {
|
||||
navigator.clipboard.writeText(
|
||||
`${$page.url.origin}/post/${
|
||||
$authData?.instance ?? DEFAULT_INSTANCE_URL
|
||||
}/${postRes.post.id}`
|
||||
)
|
||||
if (typeof navigator != 'undefined') {
|
||||
navigator.clipboard.writeText(
|
||||
`${$page.url.origin}/post/${
|
||||
$authData?.instance ?? DEFAULT_INSTANCE_URL
|
||||
}/${postRes.post.id}`
|
||||
)
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Icon src={Square2Stack} width={16} mini />
|
||||
|
||||
@@ -4,10 +4,8 @@
|
||||
function formatRelativeDate(date: Date) {
|
||||
const now = Date.now()
|
||||
|
||||
// Calculate the difference in milliseconds between 'now' and 'date'
|
||||
const diffInMillis = now - date.getTime()
|
||||
|
||||
// Define time thresholds for different units (milliseconds)
|
||||
const thresholds = [
|
||||
{ unit: 'second', threshold: 1000 },
|
||||
{ unit: 'minute', threshold: 60 * 1000 },
|
||||
@@ -16,16 +14,13 @@
|
||||
{ unit: 'week', threshold: 7 * 24 * 60 * 60 * 1000 },
|
||||
{ unit: 'month', threshold: 30 * 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--) {
|
||||
if (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(navigator.language, {
|
||||
const rtf = new Intl.RelativeTimeFormat('en', {
|
||||
numeric: 'always',
|
||||
style: 'long',
|
||||
})
|
||||
@@ -34,7 +29,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
return 'Now' // If none of the above conditions match defaulting to "Now"
|
||||
return 'Now'
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in new issue
Block a user