From cc45f0659c7db295d756d3ab49aa305122b1af9f Mon Sep 17 00:00:00 2001 From: Shine Date: Thu, 19 Dec 2024 22:32:33 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Event:=20Incorrect=20Time=20Zone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add "Time zone" input field. - 24-Hour time format. - Set Min-Year and Max-Year dynamically --- src/forms/static/event.php | 24 +- src/forms/static/timezones.html | 491 ++++++++++++++++++++++++++ src/lib/StaticQrcode/StaticQrcode.php | 29 +- src/static_qrcode.php | 16 +- 4 files changed, 535 insertions(+), 25 deletions(-) create mode 100644 src/forms/static/timezones.html diff --git a/src/forms/static/event.php b/src/forms/static/event.php index 6a50d59..e2aa162 100644 --- a/src/forms/static/event.php +++ b/src/forms/static/event.php @@ -1,15 +1,16 @@
+
+
+ + +
+
+
-
-
- - -
-
- +
@@ -33,6 +34,15 @@
+ +
+
+ + +
+
diff --git a/src/forms/static/timezones.html b/src/forms/static/timezones.html new file mode 100644 index 0000000..f9fca12 --- /dev/null +++ b/src/forms/static/timezones.html @@ -0,0 +1,491 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/lib/StaticQrcode/StaticQrcode.php b/src/lib/StaticQrcode/StaticQrcode.php index dbac7cd..da8ca9a 100644 --- a/src/lib/StaticQrcode/StaticQrcode.php +++ b/src/lib/StaticQrcode/StaticQrcode.php @@ -214,30 +214,37 @@ class StaticQrcode { * @string summary * @string url */ - public function eventQrcode($title, $start, $end, $location, $description, $url) + public function eventQrcode($title, $start, $end, $timezone, $location, $description, $url) { - if($description != NULL && $start != NULL && $end != NULL){ + if($title != NULL && $start != NULL && $end != NULL){ header('Content-Type: text/calendar; charset=utf-8'); header('Content-Disposition: attachment; filename=invite.ics'); - + + $timezoneFrom = $timezone; + + if(empty($timezoneFrom)){ + $timezoneFrom = 'Europe/Berlin'; + } + + $tmpStart = new DateTime($start, new DateTimeZone($timezoneFrom)); + $tmpEnd = new DateTime($end, new DateTimeZone($timezoneFrom)); + $tmpStart->setTimezone(new DateTimeZone("UTC")); + $tmpEnd->setTimezone(new DateTimeZone("UTC")); + $ics = new ICS(array( 'location' => $location, 'description' => $description, - 'dtstart' => $start, - 'dtend' => $end, + 'dtstart' => $tmpStart->format("Y-m-d H:i:s"), + 'dtend' => $tmpEnd->format("Y-m-d H:i:s"), 'summary' => $title, 'url' => $url )); $this->sData = $ics->to_string(); $this->sContent = '
'; - - $this->sContent .= 'Title: '.$title.'
'.'Start event: '.$start.'
'.'End event: '.$end.'
'; - + $this->sContent .= 'Title: '.$title.'
'.'Start event: '.$start.'
'.'End event: '.$end.'
'.'Time zone: '.$timezone.'
'; $this->sContent .= '
'; - - $this->sContent .= 'Location: '.$location.'
'.'Description: '.$description.'
'.'URL: '.$url.'
'; - + $this->sContent .= 'Location: '.$location.'
'.'Description: '.$description.'
'.'URL: '.$url.''; $this->sContent .= ''; $this->addQrcode("event"); diff --git a/src/static_qrcode.php b/src/static_qrcode.php index 35f159b..e1af943 100644 --- a/src/static_qrcode.php +++ b/src/static_qrcode.php @@ -51,7 +51,7 @@ if($_SERVER["REQUEST_METHOD"] === "POST" && !isset($_POST["edit"])) { case 'vcard': $static_qrcode_instance->vcardQrcode($_POST['full_name'], $_POST['nickname'], $_POST['email'], $_POST['website'], $_POST['phone'], $_POST['home_phone'], $_POST['work_phone'], $_POST['company'], $_POST['role'], $_POST['categories'], $_POST['note'], $_POST['photo'], $_POST['address'], $_POST['city'], $_POST['post_code'], $_POST['state']); break; - case 'event': $static_qrcode_instance->eventQrcode($_POST['title'], $_POST['start'], $_POST['end'], $_POST['location'], $_POST['description'], $_POST['url']); + case 'event': $static_qrcode_instance->eventQrcode($_POST['title'], $_POST['start'], $_POST['end'], $_POST['timezone'], $_POST['location'], $_POST['description'], $_POST['url']); break; case 'bookmark': $static_qrcode_instance->bookmarkQrcode($_POST['url'], $_POST['title']); @@ -162,23 +162,25 @@ $(document).ready(function(){ $('#start').daterangepicker({ timePicker: true, + timePicker24Hour: true, singleDatePicker: true, showDropdowns: true, - minYear: 2020, - maxYear: 2030, + minYear: parseInt(moment().subtract(2, 'years').format('YYYY'), 10), + maxYear: parseInt(moment().add(8, 'years').format('YYYY'), 10), locale: { - format: 'YYYY-MM-DD hh:mm A' + format: 'YYYY-MM-DD HH:mm' } }) $('#end').daterangepicker({ timePicker: true, + timePicker24Hour: true, singleDatePicker: true, showDropdowns: true, - minYear: 2020, - maxYear: 2030, + minYear: parseInt(moment().subtract(2, 'years').format('YYYY'), 10), + maxYear: parseInt(moment().add(8, 'years').format('YYYY'), 10), locale: { - format: 'YYYY-MM-DD hh:mm A' + format: 'YYYY-MM-DD HH:mm' } })