8000 `useTemporal` | Add temporal support by polyfill · Issue #4792 · vueuse/vueuse · GitHub
[go: up one dir, main page]

Skip to content
useTemporal | Add temporal support by polyfill #4792
@JonathanSchndr

Description

@JonathanSchndr

Clear and concise description of the problem

As a developer using VueUse, I want to have access to the modern Temporal API through a Vue composable so that I can handle dates, times, and timezones more reliably and consistently across different calendar systems. The current Date object has many limitations and inconsistencies that the Temporal API solves.

This implementation provides a reactive wrapper around the Temporal API using the @js-temporal/polyfill package, offering:

  • 🌍 Timezone conversion and management
  • 📅 Multiple calendar system support (Gregorian, Islamic, Hebrew, etc.)
  • ⚡ Reactive updates with configurable intervals
  • 🎯 Full TypeScript support
  • 🔧 Rich set of date/time manipulation utilities

I have already implemented this feature and am submitting a PR (#4793).

Suggested solution

In the VueUse integrations module, we have implemented useTemporal composable that provides a reactive interface to the Temporal API:

  1. Core Features:

    • Reactive Temporal.ZonedDateTime with auto-updates
    • Timezone conversion utilities
    • Calendar system switching
    • Duration-based calculations
    • Formatting options
  2. Implementation Details:

    • Uses @js-temporal/polyfill for browser compatibility
    • Provides both composable (useTemporal) and utility (createTemporal) functions
    • Full TypeScript support with proper types
    • Comprehensive test coverage
    • Demo component showcasing main features
  3. API Structure:

    • Simple configuration options (timezone, calendar, interval, immediate)
    • Intuitive methods for common operations
    • Consistent with Vue's reactivity system
    • Proper cleanup and lifecycle management

The implementation is complete with full documentation, tests, and a demo component showing real-world usage scenarios.

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0