---
import { omit } from 'lodash-es'

import { formatDateShort, type FormatDateShortOptions } from '../lib/timeAgo'

import type { HTMLAttributes } from 'astro/types'

type Props = FormatDateShortOptions &
  Omit<HTMLAttributes<'time'>, keyof FormatDateShortOptions | 'datetime'> & {
    date: Date
  }

const { date, ...props } = Astro.props
---

<time datetime={date.toISOString()} {...omit(props, 'prefix')}>{formatDateShort(date, props)}</time>
