Features
- Adapter pattern for date library abstraction
- Locale-aware formatting via Intl.DateTimeFormat
- Integration with useLocale for automatic locale sync
- Temporal API support (Vuetify0DateAdapter)
- Arithmetic operations (add/subtract days, months, etc.)
- Comparison utilities (isBefore, isAfter, etc.)
Installation
Basic Usage
API Reference
createDatePlugin()
Creates a date plugin with adapter.Plugin configuration
Date adapter instance (e.g.,
new Vuetify0DateAdapter())Default locale for formatting (e.g., ‘en-US’, ‘de-DE’)
Short locale codes mapped to full Intl locale stringsExample:
{ en: 'en-US', de: 'de-DE' }The namespace for the date context
DateContext
The date adapter instance with date manipulation methods
Current locale (reactive, synced with useLocale if available)
DateAdapter Methods
Construction
Create a date from various inputs (ISO string, timestamp, Date object, etc.)
Convert adapter date to JavaScript Date
Parse ISO 8601 string to date
Convert date to ISO 8601 string
Check if a value is a valid date
Formatting
Format date using preset formats:
'fullDate': Full date (e.g., ‘January 15, 2024’)'shortDate': Short date (e.g., ‘1/15/24’)'normalDate': Normal date (e.g., ‘Jan 15, 2024’)'year': Year only (e.g., ‘2024’)'month': Full month (e.g., ‘January’)'monthShort': Short month (e.g., ‘Jan’)'dayOfMonth': Day of month (e.g., ‘15’)'hours12h': 12-hour format (e.g., ‘2 PM’)'hours24h': 24-hour format (e.g., ‘14’)'fullTime': Full time with seconds
Format date using token string:
YYYY: 4-digit yearMM: 2-digit monthDD: 2-digit dayHH: 2-digit hours (24h)hh: 2-digit hours (12h)mm: 2-digit minutesss: 2-digit secondsA: AM/PM
Arithmetic
Add/subtract minutes (negative for subtraction)
Add/subtract hours
Add/subtract days
Add/subtract weeks
Add/subtract months
Add/subtract years
Comparison
Check if date is after comparing date
Check if date is before comparing date
Check if dates are equal
Check if dates are on the same day
Check if dates are in the same month
Check if dates are in the same year
Check if date is within range (inclusive)
Boundaries
Get start of day (midnight)
Get end of day (23:59:59)
Get start of week (0 = Sunday, 1 = Monday)
Get end of week
Get start of month
Get end of month
Get start of year
Get end of year
Getters
Get year (4-digit)
Get month (0-indexed: 0 = January)
Get day of month (1-31)
Get hours (0-23)
Get minutes (0-59)
Get seconds (0-59)
Get difference between dates in specified unit (days, hours, minutes, etc.)