How tc39/proposal-intl-datetimeformat-formatrange works
Major Components
• API Layer: Represent the extensions to Intl.DateTimeFormat (the two new methods: formatRange and formatRangeToParts). This is the public interface that developers use.
• Formatting Engine: This module contains the core logic that compares two date objects, determines the largest different calendar field between them, and chooses the correct localized patterns based on CLDR/ICU rules.
• Test / Specification Module: The presence of a spec.emu file indicates that there is a specification-guided test or validation suite ensuring compliance with the proposal.
• Build & Configuration: Files like package.json, .npmrc, and index.html (likely used for demo purposes) signify that there is a build process and a demonstration page that encapsulates how the library will be used.
Architectural Patterns and Design Principles
• Modular separation by grouping the concerns:
• API / Entry Point
• Business Logic (Formatting Engine)
• Data Dependency (Locale Data)
• Testing Module
• That although this is a polyfill or enhancement library, the design follows a layered approach (presentation → business logic → data source).