@include('filament.pages.astrology.partials.styles') {{ $this->form }} @if ($apiCall) @include('filament.pages.astrology.partials.api-call') @endif @if ($result) @php $tool = \App\Filament\Pages\Astrology\FestivalsTool::class; $timezone = $result['location']['timezone'] ?? config('astrology.default_timezone'); $today = now($timezone)->format('Y-m-d'); $all = $result['festivals'] ?? []; $namesById = array_column($all, 'name', 'id') + $tool::PERIOD_NAMES; $placeLabel = collect(\App\Filament\Pages\Astrology\AstrologyToolPage::PLACES) ->first(fn (array $place): bool => abs($place['latitude'] - $result['location']['latitude']) < 0.001 && abs($place['longitude'] - $result['location']['longitude']) < 0.001)['label'] ?? sprintf('%.4f, %.4f', $result['location']['latitude'], $result['location']['longitude']); $name = function (array $event): string { $rule = $event['rule'] ?? []; return match ($event['id']) { 'purnima', 'amavasya' => trim(($rule['month'] ?? '').' '.$event['name'].($event['id'] === 'purnima' ? ' (full moon)' : ' (new moon)').(! empty($rule['adhika']) ? ' (Adhika (extra month))' : '')), 'sankranti' => trim(($rule['to_sign'] ?? '').' '.$event['name']), default => $event['name'], }; }; $rule = function (array $event) use ($namesById): string { $rule = $event['rule'] ?? []; $eclipseTypes = ['total' => 'Total', 'partial' => 'Partial', 'annular' => 'Annular', 'hybrid' => 'Hybrid', 'penumbral' => 'Penumbral']; return match ($rule['type'] ?? null) { 'tithi' => implode(' ', array_filter([$rule['month'] ?? '', ! empty($rule['adhika']) ? 'Adhika (extra month)' : '', $rule['paksha'] ?? '', $rule['tithi'] ?? ''])), 'nakshatra' => implode(' · ', array_filter([$rule['month'] ?? '', $rule['nakshatra'] ?? ''])), 'sankranti' => 'Sun enters '.($rule['to_sign'] ?? ''), 'eclipse' => $eclipseTypes[$rule['eclipse'] ?? ''] ?? ($rule['eclipse'] ?? ''), 'derived' => ($event['id'] === 'varalakshmi_vrat' ? 'Friday before ' : 'Day after ').($namesById[$rule['after'] ?? ''] ?? ($rule['after'] ?? '')), default => '', }; }; /** "06:51 AM", or "06:51 AM, 14 Nov" when the instant falls on another day than $day. */ $time = function (?string $iso, string $day) use ($timezone): string { if (! $iso) { return '—'; } $moment = \Carbon\CarbonImmutable::parse($iso)->setTimezone($timezone); return $moment->format('h:i A').($moment->format('Y-m-d') === $day ? '' : $moment->format(', j M')); }; $kalaLabels = [ 'purvahna' => 'Purvahna puja time (morning)', 'madhyahna' => 'Madhyahna puja time (midday)', 'aparahna' => 'Aparahna time (afternoon)', 'sayahna' => 'Sayahna time (evening)', 'pradosh' => 'Pradosh puja time', 'nishita' => 'Nishita puja time (midnight)', 'arunodaya' => 'Arunodaya snan (pre-dawn)', 'moonrise' => 'Moonrise', ]; $timingRows = function (array $event) use ($time, $kalaLabels): array { $day = $event['date']; $rows = []; if (! empty($event['starts']) && ! empty($event['ends'])) { $label = match ($event['kind']) { 'eclipse' => 'Eclipse', 'nakshatra' => 'Nakshatra', default => 'Tithi', }; $rows[] = [$label, $time($event['starts'], $day).' – '.$time($event['ends'], $day)]; } if (! empty($event['muhurta'])) { $rows[] = [$kalaLabels[$event['muhurta']['kala'] ?? ''] ?? 'Muhurta', $time($event['muhurta']['start'], $day).' – '.$time($event['muhurta']['end'], $day)]; } if (! empty($event['parana'])) { $rows[] = ['Parana (breaking the fast)', $time($event['parana']['start'], $day).' – '.$time($event['parana']['end'], $day)]; } if (! empty($event['instant'])) { $rows[] = [$event['kind'] === 'eclipse' ? 'Greatest eclipse' : 'Exact moment', $time($event['instant'], $day)]; } return $rows; }; $daysUntil = fn (string $date): int => (int) \Carbon\CarbonImmutable::parse($today)->diffInDays(\Carbon\CarbonImmutable::parse($date), false); $status = function (string $date) use ($daysUntil): ?string { $days = $daysUntil($date); return match (true) { $days === 0 => 'Today', $days === 1 => 'Tomorrow', $days > 1 && $days <= 60 => "in {$days} days", default => null, }; }; $periodStatus = function (array $period) use ($today, $daysUntil): array { if ($today >= $period['start'] && $today <= $period['end']) { return ['Day '.(1 - $daysUntil($period['start'])).' of '.$period['days'], true]; } return $today < $period['start'] ? ['in '.$daysUntil($period['start']).' days', false] : ['Ended', false]; }; $filtered = $majorOnly ? array_values(array_filter($all, fn ($event) => $event['major'])) : $all; $upcoming = array_values(array_filter($filtered, fn ($event) => $event['date'] >= $today)); $pastCount = count($filtered) - count($upcoming); $visible = $showPast || $pastCount === 0 ? $filtered : $upcoming; $nextUp = array_slice(array_values(array_filter($all, fn ($event) => $event['major'] && $event['date'] >= $today)), 0, 3); $months = collect($visible)->groupBy(fn ($event) => substr($event['date'], 0, 7)); $periods = array_values(array_filter($result['periods'] ?? [], fn ($period) => $showPast || $period['end'] >= $today)); $hasEclipse = collect($all)->contains('kind', 'eclipse'); @endphp
{{-- Header --}}

Hindu Festivals

Festival, vrat and Shraddha dates for your city

Every festival, Ekadashi, Sankranti, eclipse and Pitru Paksha tithi is computed from the ephemeris for the place you choose, with exact local timings.

{{ $result['year'] - 1 }} {{ $result['year'] }} {{ $result['year'] + 1 }}
@if ($pastCount > 0) · {{ $pastCount }} dates @endif

Calculated for {{ $placeLabel }}; every time shown is local to that place ({{ $timezone }}). The same festival can fall a day earlier or later in another city.

{{-- Special periods --}} @if ($periods !== [])

Special periods

@foreach ($periods as $period) @php $theme = $tool::theme($period['id']); [$label, $live] = $periodStatus($period); @endphp
{{ $theme['glyph'] }}
{{ $tool::PERIOD_NAMES[$period['id']] ?? $namesById[$period['id']] ?? \Illuminate\Support\Str::headline($period['id']) }}{{ ! empty($period['month']) ? ' · '.$period['month'] : '' }} {{ $label }}
{{ \Carbon\CarbonImmutable::parse($period['start'])->format('j M') }} – {{ \Carbon\CarbonImmutable::parse($period['end'])->format('j M Y') }} · {{ $period['days'] }} days
@endforeach
@endif {{-- Next up --}} @if ($nextUp !== [] && ! $showPast)

Next up

@foreach ($nextUp as $event) @include('filament.pages.astrology.partials.festival-hero', ['event' => $event, 'compact' => true]) @endforeach
@if (collect($nextUp)->contains('kind', 'eclipse'))

Eclipse times are geocentric and the eclipse may not be visible from your city.

@endif
@endif {{-- Month by month --}} @if ($months->isEmpty())

No festivals to show for this selection.

@endif @foreach ($months as $monthKey => $events)

{{ \Carbon\CarbonImmutable::parse($monthKey.'-01')->format('F Y') }}

{{ count($events) }} dates
    @foreach ($events as $event) @if ($event['major'])
  • @include('filament.pages.astrology.partials.festival-hero', ['event' => $event, 'compact' => false])
  • @else @php $theme = $tool::theme($event['id']); $eventStatus = $status($event['date']); $date = \Carbon\CarbonImmutable::parse($event['date']); @endphp
  • {{ $date->format('j') }}{{ $date->format('D') }}
    {{ $theme['glyph'] }}
    {{ $name($event) }} @if ($eventStatus){{ $eventStatus }}@endif
    {{ $rule($event) }}
    @if ($rows = $timingRows($event))
    @foreach ($rows as [$label, $value]) {{ $label }}: {{ $value }} @endforeach
    @endif
  • @endif @endforeach
@endforeach @if ($hasEclipse)

Eclipse times are geocentric and the eclipse may not be visible from your city.

@endif
@include('filament.pages.astrology.partials.raw-json') @endif