Skip to content

Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.

fix: use RFC 5545 compliant date format in iCal exports (#965)

Pedro Pombeirob6b0abed0d91
diff --git a/api/subscriptions/get_ical_feed.php b/api/subscriptions/get_ical_feed.php
index f311a74..b454e4a 100644
--- a/api/subscriptions/get_ical_feed.php
+++ b/api/subscriptions/get_ical_feed.php
@@ -175,6 +175,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST" || $_SERVER["REQUEST_METHOD"] === "GET
$uid = uniqid();
$summary = html_entity_decode($subscription['name'], ENT_QUOTES, 'UTF-8');
$description = "Price: {$subscription['currency']}{$subscription['price']}\\nCategory: {$subscription['category']}\\nPayment Method: {$subscription['payment_method']}\\nPayer: {$subscription['payer_user']}\\nNotes: {$subscription['notes']}";
+ $dtstamp = gmdate('Ymd\THis\Z');
$dtstart = (new DateTime($subscription['next_payment']))->format('Ymd');
$dtend = (new DateTime($subscription['next_payment']))->format('Ymd');
$location = isset($subscription['url']) ? $subscription['url'] : '';
@@ -183,10 +184,11 @@ if ($_SERVER["REQUEST_METHOD"] === "POST" || $_SERVER["REQUEST_METHOD"] === "GET
$icsContent .= <<<ICS
BEGIN:VEVENT
UID:$uid
+ DTSTAMP:$dtstamp
SUMMARY:$summary
DESCRIPTION:$description
- DTSTART:$dtstart
- DTEND:$dtend
+ DTSTART;VALUE=DATE:$dtstart
+ DTEND;VALUE=DATE:$dtend
LOCATION:$location
STATUS:CONFIRMED
TRANSP:OPAQUE
@@ -196,7 +198,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST" || $_SERVER["REQUEST_METHOD"] === "GET
TRIGGER:$alarm_trigger
END:VALARM
END:VEVENT
-
+
ICS;
}
diff --git a/endpoints/subscription/exportcalendar.php b/endpoints/subscription/exportcalendar.php
index b44d6e0..bc7df00 100644
--- a/endpoints/subscription/exportcalendar.php
+++ b/endpoints/subscription/exportcalendar.php
@@ -35,8 +35,9 @@ if ($subscription) {
$summary = html_entity_decode($subscription['name'], ENT_QUOTES, 'UTF-8');
$description = "Price: {$subscription['currency']}{$subscription['price']}\nCategory: {$subscription['category']}\nPayment Method: {$subscription['payment_method']}\nPayer: {$subscription['payer_user']}\n\nNotes: {$subscription['notes']}";
- $dtstart = (new DateTime($subscription['next_payment']))->format('Ymd\THis\Z');
- $dtend = (new DateTime($subscription['next_payment']))->modify('+1 hour')->format('Ymd\THis\Z');
+ $dtstamp = gmdate('Ymd\THis\Z');
+ $dtstart = (new DateTime($subscription['next_payment']))->format('Ymd');
+ $dtend = (new DateTime($subscription['next_payment']))->format('Ymd');
$location = isset($subscription['url']) ? $subscription['url'] : '';
$alarm_trigger = '-P' . $subscription['trigger'] . 'D';
@@ -48,10 +49,11 @@ if ($subscription) {
METHOD:PUBLISH
BEGIN:VEVENT
UID:$uid
+ DTSTAMP:$dtstamp
SUMMARY:$summary
DESCRIPTION:$description
- DTSTART:$dtstart
- DTEND:$dtend
+ DTSTART;VALUE=DATE:$dtstart
+ DTEND;VALUE=DATE:$dtend
LOCATION:$location
STATUS:CONFIRMED
TRANSP:OPAQUE