{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "use-date",
  "title": "useDate",
  "description": "A reactive current date/time hook with Jalali/Gregorian support, formatted output, and optional holiday flagging.",
  "registryDependencies": [
    "@persianlabsui/persian-date",
    "@persianlabsui/persian-holidays"
  ],
  "files": [
    {
      "path": "registry/base/hooks/use-date.ts",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport {\n  formatDate,\n  toParts,\n  type CalendarType,\n  type DateLocale,\n  type DigitStyle,\n} from \"@/lib/persian-date\"\nimport {\n  getHolidayInfo,\n  isHoliday,\n  type ResolvedHoliday,\n} from \"@/lib/persian-holidays\"\n\nexport interface UseDateOptions {\n  /** @default \"shamsi\" */\n  calendarType?: CalendarType\n  locale?: DateLocale\n  digits?: DigitStyle\n  /** Tick interval in milliseconds. Set 0 to read the time once and never update. @default 1000 */\n  interval?: number\n  /** Format pattern used for `formatted`. @default \"yyyy/MM/dd HH:mm:ss\" */\n  pattern?: string\n  /** Flag `date` against the built-in Iranian holiday dataset. @default false */\n  checkHoliday?: boolean\n}\n\nexport interface UseDateResult {\n  /** The live Date value. */\n  date: Date\n  /** `date` formatted with `pattern`, honoring calendarType/locale/digits. */\n  formatted: string\n  /** 1-indexed year/month/day in the active calendarType. */\n  year: number\n  month: number\n  day: number\n  hour: number\n  minute: number\n  second: number\n  /** 0 (Sunday) - 6 (Saturday), same in both calendars -- a real-world invariant. */\n  weekday: number\n  isHoliday: boolean\n  /** Populated only when checkHoliday is true and `date` matches an entry. */\n  holidays: ResolvedHoliday[]\n}\n\n/**\n * A reactive current date/time hook with built-in Jalali/Gregorian calendar\n * support. Ticks on an interval (every second by default) and re-renders\n * with the latest value.\n *\n * Returns `null` until the hook has run in the browser -- `new Date()` reads\n * differently on the server than on the client, so rendering it during SSR\n * would produce a hydration mismatch. Same convention as `useCountdown`.\n */\nexport function useDate(options: UseDateOptions = {}): UseDateResult | null {\n  const {\n    calendarType = \"shamsi\",\n    locale,\n    digits,\n    interval = 1000,\n    pattern = \"yyyy/MM/dd HH:mm:ss\",\n    checkHoliday = false,\n  } = options\n\n  const [date, setDate] = React.useState<Date | null>(null)\n\n  React.useEffect(() => {\n    const update = () => setDate(new Date())\n    update()\n\n    if (interval <= 0) return\n\n    const id = setInterval(update, interval)\n    return () => clearInterval(id)\n  }, [interval])\n\n  return React.useMemo(() => {\n    if (date == null) return null\n\n    const parts = toParts(date, calendarType)\n    return {\n      date,\n      formatted: formatDate(date, pattern, { calendarType, locale, digits }),\n      year: parts.year,\n      month: parts.month,\n      day: parts.day,\n      hour: date.getHours(),\n      minute: date.getMinutes(),\n      second: date.getSeconds(),\n      weekday: date.getDay(),\n      isHoliday: checkHoliday ? isHoliday(date) : false,\n      holidays: checkHoliday ? getHolidayInfo(date) : [],\n    }\n  }, [date, calendarType, locale, digits, pattern, checkHoliday])\n}\n",
      "type": "registry:hook"
    }
  ],
  "type": "registry:hook"
}