Overview
The date formatter utility provides timezone-aware date decomposition, breaking timestamps into comprehensive components including year, month, week numbers, and day-of-year calculations. Source:src/tools/dateFormatter.ts
decomposeTime
Decomposes a Unix timestamp into detailed date and time components with timezone support.Parameters
Unix timestamp in milliseconds to decompose
Configuration options for timezone handling
IANA timezone identifier (e.g., “America/Bogota”, “UTC”, “Europe/London”)
Returns
Object containing decomposed date and time information
Four-digit year
Two-digit month (01-12)
Three-letter month abbreviation (JAN, FEB, MAR, etc.)
ISO week number of the year
Day of week as number (1-7, Monday=1)
Three-letter day abbreviation (MON, TUE, WED, THU, FRY, SAT, SUN)
Day number within the year (1-366)
Two-digit day of month (01-31)
Two-digit hour in 24-hour format (00-23)
Two-digit minute (00-59)
Two-digit second (00-59)
Milliseconds portion of the timestamp
Examples
This function uses
Intl.DateTimeFormat for timezone-aware parsing and the weeknumber library for ISO week calculations. The default timezone is “America/Bogota” if not specified.Use Cases
- Generating UBL date/time fields with specific timezone requirements
- Creating invoice timestamps with localized formatting
- Extracting week numbers for period-based reporting
- Converting timestamps for tax document compliance