Skip to content

Commit

Permalink
Small naming change
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvanassche committed Jun 25, 2024
1 parent 89b9d54 commit 609bd9e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions config/data.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
'date_format' => DATE_ATOM,

/**
* Set a default timezone for casting date
* When transforming or casting dates, the following timezone will be used to
* convert the date to the correct timezone. If set to null no timezone will
* be passed.
*/
'default_timezone' => null,
'date_timezone' => null,

/**
* It is possible to enable certain features of the package, these would otherwise
Expand Down
2 changes: 1 addition & 1 deletion src/Casts/DateTimeInterfaceCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function castValue(
throw CannotCastDate::create($formats->toArray(), $type, $value);
}

$this->setTimeZone ??= config('data.default_timezone');
$this->setTimeZone ??= config('data.date_timezone');

if ($this->setTimeZone) {
return $datetime->setTimezone(new DateTimeZone($this->setTimeZone));
Expand Down
2 changes: 1 addition & 1 deletion src/Transformers/DateTimeInterfaceTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(

public function transform(DataProperty $property, mixed $value, TransformationContext $context): string
{
$this->setTimeZone ??= config('data.default_timezone');
$this->setTimeZone ??= config('data.date_timezone');

/** @var DateTimeInterface $value */
if ($this->setTimeZone) {
Expand Down

0 comments on commit 609bd9e

Please sign in to comment.