Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

670 B
Raw Blame
import type { WebAnalyticsRecapResponseApi } from 'products/web_analytics/frontend/generated/api.schemas'

function parseApiDate(date: string): Date {
    const [year, month, day] = date.split('-').map(Number)
    return new Date(year, month - 1, day)
}

function formatApiDate(date: string): string {
    return new Intl.DateTimeFormat(undefined, {
        month: 'short',
        day: 'numeric',
        year: 'numeric',
    }).format(parseApiDate(date))
}

export function formatRecapDateRange(recap: Pick<WebAnalyticsRecapResponseApi, 'period_start' | 'period_end'>): string {
    return `${formatApiDate(recap.period_start)} - ${formatApiDate(recap.period_end)}`
}