Skip to content

Add DateTimeRange object for datetime ranges - #2857

Merged
calebporzio merged 1 commit into
mainfrom
datetime-range
Oct 15, 2026
Merged

calebporzio merged 1 commit into
mainfrom
datetime-range

Conversation

@calebporzio

@calebporzio calebporzio commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

The scenario

Flux Pro is adding a datetime picker with a range mode. Range values need to round-trip through Livewire with their times intact.

The problem

Flux\DateRange only stores dates. Its synth serializes Y-m-d, so binding it to a datetime range drops the times.

The solution

This adds Flux\DateTimeRange, a CarbonPeriod subclass like DateRange, plus a Livewire synth that serializes both ends as Y-m-d\TH:i (the format the datetime picker and native datetime-local inputs use).

public ?DateTimeRange $window;

$this->window = new DateTimeRange(now()->setTime(22, 0), now()->addDay()->setTime(2, 0));
  • The range's timezone travels in the synth metadata, so it survives requests and new selections are parsed in the same timezone.
  • A range needs both ends: partial or empty values hydrate to null, and unsetting either end clears it.
  • unwrapForValidation exposes start/end strings for range.start style rules.
  • It works with whereBetween() like any CarbonPeriod.

Flux Pro PR: https://github.com/livewire/flux-pro/pull/588
Docs PR: https://github.com/livewire/flux-docs/pull/244

Verification

  • Round-trip checks (timezone preserved, nested set, unset, whole-object hydrate, null/partial values, validation unwrap)
  • Flux Pro datetime picker Playwright tests binding a DateTimeRange property (pre-filled and empty)

🤖 Generated with Claude Code

A CarbonPeriod-based range that keeps the time of day for both ends, for
binding the datetime picker's range mode with wire:model. The range's
timezone travels in the synth metadata so it survives requests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@calebporzio
calebporzio merged commit ef9750f into main Oct 15, 2026
1 check passed
@calebporzio
calebporzio deleted the datetime-range branch October 15, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant