ComponentĐa ngôn ngữ
Bắt đầu nhanh
Import Date Utilities từ entry công khai. Các ví dụ bên dưới thể hiện những kiểu tương tác và cấu hình được hỗ trợ.
component.tsxtsx
import { DateUtils } from '@underverse-ui/underverse';Ví dụ tương tác
Dùng thử Date Utilities thật, xem mã ví dụ và tra cứu các prop đã được mô tả.
Đang tải ví dụ tương tác…
Tham chiếu
Tham chiếu API
Tra cứu các thuộc tính, kiểu dữ liệu được chấp nhận, giá trị mặc định và lưu ý về hành vi.
Dữ liệu được sinh từ API TypeScript công khai của thư viện. Kiểu dữ liệu, thuộc tính bắt buộc và giá trị mặc định luôn đồng bộ với mã nguồn.
DateUtils
Namespace| API | Kiểu | Mô tả |
|---|---|---|
| formatDate | (date: string | Date | null | undefined, locale?: SupportedLocale) => string | Format date to readable format |
| formatDateShort | (date: string | Date | null | undefined, locale?: SupportedLocale) => string | Format date to short format |
| formatTime | (date: string | Date | null | undefined, locale?: SupportedLocale) => string | Format time only |
| formatDateTime | (date: string | Date | null | undefined, locale?: SupportedLocale) => string | Format date and time |
| formatTimeAgo | (date: string | Date | null | undefined, locale?: SupportedLocale) => string | Format relative time (time ago) |
| isToday | (date: string | Date | null | undefined) => boolean | Check if date is today |
| isYesterday | (date: string | Date | null | undefined) => boolean | Check if date is yesterday |
| formatDateForInput | (date: string | Date | null | undefined) => string | Format date for input[type="date"] |
| formatDateTimeForInput | (date: string | Date | null | undefined) => string | Format date for input[type="datetime-local"] |
| getDayOfWeek | (date: string | Date | null | undefined, locale?: SupportedLocale) => string | Get day of week |
| formatDateWithDay | (date: string | Date | null | undefined, locale?: SupportedLocale) => string | Format with day of week |
| formatDateSmart | (date: string | Date | null | undefined, locale?: SupportedLocale) => string | Smart date formatting - shows relative time for recent dates, full date for older ones |
| parseDateString | (str: string, locale?: SupportedLocale) => Date | null | Parse date string based on locale |
Hướng dẫn sử dụng
Cấu hình Date Utilities tại biên ứng dụng. Giữ nguyên placeholder cùng quy tắc ngày, số và số nhiều cho mọi locale được hỗ trợ.
Trợ năng
Khi dùng Date Utilities, hãy giữ trạng thái focus dễ nhận biết, cung cấp tên truy cập khi cần và kiểm tra bàn phím cùng trình đọc màn hình trong ngữ cảnh thực tế.
