# useDateFormat URL: /docs/native/hooks/use-date-format Provider-agnostic date, datetime and time formatting context for Docyrus native components. Wired automatically by DocyrusTenantProvider, but works with any date library. ## Installation ```bash pnpm dlx @docyrus/cli add @docyrus/rn-hooks-use-date-format ``` The module exports `useDateFormat()` (hook), `; } ``` ### Custom provider (date-fns) ```tsx import { format } from 'date-fns'; import { DateFormatProvider } from '@/hooks/docyrus-native/use-date-format'; export function AppProviders({ children }: { children: React.ReactNode }) { return ( ); } ``` ## API Reference ### `useDateFormat()` Takes no parameters. **Returns:** `DateFormatContextValue`. | Field | Type | Description | |-------|------|-------------| | `formatDate` | `(value: unknown) => string` | Date-only output. | | `formatDateTime` | `(value: unknown) => string` | Date and time output. | | `formatTime` | `(value: unknown) => string` | Time-only output. | ### `` | Prop | Type | Default | Description | |------|------|---------|-------------| | `formatDate` | `DateFormatFn` | — | Required. Backs `formatDate` inside the tree. | | `formatDateTime` | `DateFormatFn` | — | Required. Backs `formatDateTime` inside the tree. | | `formatTime` | `DateFormatFn` | — | Required. Backs `formatTime` inside the tree. | | `children` | `ReactNode` | — | Tree to wrap. | ### `isDefaultDateFormatContext(ctx)` | Parameter | Type | Description | |-----------|------|-------------| | `ctx` | `DateFormatContextValue` | A value returned by `useDateFormat()`. | **Returns:** `boolean`. `true` when `ctx` is the no-provider sentinel rather than a real provider. Listing hooks use it so they don't shadow a cell's own fallback formatting when no provider is mounted. ### `DateFormatContext` The raw context (`DateFormatContextValue | null`, `null` without a provider). Native-only export: the native data-grid cell reads it directly. Prefer `useDateFormat()` in app code. ## Type Exports | Type | Description | |------|-------------| | `DateFormatFn` | `(value: unknown) => string`. | | `DateFormatContextValue` | Shape returned by `useDateFormat()`. |