Skip to content

Commit

Permalink
allow null timezone for entries
Browse files Browse the repository at this point in the history
  • Loading branch information
mokhosh committed Mar 6, 2024
1 parent 5cc4427 commit d95c183
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/FilamentJalaliServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Ariaieboy\Jalali\Jalali;
use Filament\Forms\Components\DateTimePicker;
use Filament\Infolists\Components\Entry;
use Filament\Infolists\Components\TextEntry;
use Filament\Support\Assets\AlpineComponent;
use Filament\Support\Facades\FilamentAsset;
Expand Down Expand Up @@ -73,13 +74,13 @@ public function packageBooted(): void
TextEntry::macro('jalaliDate', function (?string $format = null, ?string $timezone = null) {
$format ??= config('filament-jalali.date_format');

$this->formatStateUsing(static function ($state) use ($format, $timezone): ?string {
$this->formatStateUsing(static function (Entry $entry, $state) use ($format, $timezone): ?string {
if (blank($state)) {
return null;
}

return Jalali::fromCarbon(Carbon::parse($state)
->setTimezone($timezone))
->setTimezone($timezone ?? $entry->getTimezone()))
->format($format);
});

Expand Down

0 comments on commit d95c183

Please sign in to comment.