Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump dev dependencies, update changelog #168

Merged
merged 13 commits into from
Mar 1, 2023
Prev Previous commit
Next Next commit
Add DTSTAMP to ICS generator, also use UTC timestamps instead of defi…
…ning timezone
  • Loading branch information
kodie authored and wxactly committed Feb 28, 2023
commit c2eb4d3b9e4cb6e351e35efdf92f576c876dfef0
12 changes: 6 additions & 6 deletions src/Generators/Ics.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Ics implements Generator
/** @var string {@see https://www.php.net/manual/en/function.date.php} */
protected $dateFormat = 'Ymd';
/** @var string */
protected $dateTimeFormat = 'e:Ymd\THis';
protected $dateTimeFormat = 'Ymd\THis';

/** @var array<non-empty-string, non-empty-string> */
protected $options = [];
Expand Down Expand Up @@ -41,13 +41,13 @@ public function generate(Link $link): string
$dateTimeFormat = $link->allDay ? $this->dateFormat : $this->dateTimeFormat;

if ($link->allDay) {
$url[] = 'DTSTAMP;TZID='.$link->from->format($dateTimeFormat);
$url[] = 'DTSTART:'.$link->from->format($dateTimeFormat);
$url[] = 'DTSTAMP:'.gmdate($dateTimeFormat, $link->from->getTimestamp()).'Z';
$url[] = 'DTSTART:'.gmdate($dateTimeFormat, $link->from->getTimestamp()).'Z';
$url[] = 'DURATION:P'.(max(1, $link->from->diff($link->to)->days)).'D';
} else {
$url[] = 'DTSTAMP;TZID='.$link->from->format($dateTimeFormat);
$url[] = 'DTSTART;TZID='.$link->from->format($dateTimeFormat);
$url[] = 'DTEND;TZID='.$link->to->format($dateTimeFormat);
$url[] = 'DTSTAMP:'.gmdate($dateTimeFormat, $link->from->getTimestamp()).'Z';
$url[] = 'DTSTART:'.gmdate($dateTimeFormat, $link->from->getTimestamp()).'Z';
$url[] = 'DTEND:'.gmdate($dateTimeFormat, $link->to->getTimestamp()).'Z';
}

if ($link->description) {
Expand Down