import type { DateTimeSourceZone } from '../domain/formatters';
import { formatShanghaiDateTime } from '../domain/formatters';

export function PlatformTime({
  value,
  className = '',
  empty = '—',
  sourceZone = 'preserve'
}: {
  value?: string;
  className?: string;
  empty?: string;
  sourceZone?: DateTimeSourceZone;
}) {
  const classes = ['v2-platform-time', className].filter(Boolean).join(' ');
  if (!value?.trim()) return <span className={classes}>{empty}</span>;
  return <time className={classes} dateTime={value} title={`${value} · 上海时间`}>
    {formatShanghaiDateTime(value, { empty, sourceZone })}
  </time>;
}
