ObservationDetail.DateTime
A date and time display component with flexible formatting options and fallback content support. Designed for healthcare observation timestamps with localization and conditional rendering capabilities.
Basic Example
import { ObservationDetail } from "@ovok/native";
import * as React from "react";
const BasicTimestamp = () => (
<ObservationDetail.DateTime dateTime="2024-01-15T10:30:00Z" />
);
export default BasicTimestamp;
Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
dateTime | string | required when children is absent | - | ISO date string to format and display |
format | string | only with dateTime | "dd MMMM yyyy, EEEE HH:mm" | Date format pattern |
style | StyleProp<TextStyle> | - | - | Custom text styles |
children | React.ReactNode | - | - | Fallback content when no dateTime |
The public type is based on Paper Text props, but the current renderer forwards
only style and testID to the rendered text. dateTime and children are a
discriminated union: provide a date, or provide fallback children.
Component Behavior
Date Formatting
- Uses
date-fnsfor reliable date formatting - Supports all date-fns format patterns
date-fns/formatthrows for an invalid date string; validate input before rendering- Provides localized date display
Conditional Rendering
- Shows formatted date when
dateTimeis provided - Renders
childrencontent whendateTimeis omitted. The fallback is returned as a bare fragment, so a plain string must be wrapped in a text component by the host; otherwise React Native can reject the raw string outside<Text>.