Skip to content

Commit

Permalink
chore: fix timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemilloy committed May 4, 2024
1 parent 6859bd5 commit ac5f875
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "itsnubix/nowcal",
"version": "1.2.0",
"version": "1.2.1",
"description": "A modern PHP library for generating iCalendar v2.0 events",
"keywords": [
"icalendar",
Expand Down
20 changes: 13 additions & 7 deletions src/NowCal/NowCal.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,15 +613,15 @@ protected function optionallyAddTimezoneToKey(string $key): string
*/
protected function getParameterValue(string $key): string
{
if ($this->has($key)) {
if ($this->hasCaster($key)) {
return $this->cast($this->{$key}, static::CASTS[$key]);
}
if (!$this->has($key)) {
return '';
}

return $this->{$key};
if ($this->hasCaster($key)) {
return $this->cast($this->{$key}, static::CASTS[$key]);
}

return null;
return $this->{$key};
}

/**
Expand Down Expand Up @@ -730,7 +730,13 @@ protected function convertStringToPascalCase(string $string): string
*/
protected function createDateTime(string|DateTime|Closure $datetime = 'now'): string
{
return (new DateTime($datetime))->format(static::DATETIME_FORMAT);
$datetime = new DateTime($datetime);

if ($this->timezone) {
$datetime->setTimezone(new DateTimeZone($this->timezone));
}

return $datetime->format(static::DATETIME_FORMAT);
}

/**
Expand Down

0 comments on commit ac5f875

Please sign in to comment.