GuavaCZ / calendar

MIT License
140 stars 13 forks source link

[Bug]: Timezone issue when retrieving events in the calendar #40

Closed sergioraldana closed 1 month ago

sergioraldana commented 1 month ago

What happened?

Description: I’m using the GuavaCZ/calendar package in my project, and I have the timezone configured in my .env file as:

APP_TIMEZONE='America/Guatemala'

However, when I retrieve events in the calendar, the system is adding 6 hours to them, which is incorrect for my timezone (UTC-6). To fix this, I have to manually subtract those 6 hours in the code like this:

->start(Carbon::parse($this->inicio)->subHours(6)) ->end(Carbon::parse($this->fin)->subHours(6))

Problem: The calendar does not seem to respect the timezone setting in the .env file. This forces me to manually adjust the event times every time I display them.

Expected behavior: The calendar should respect the timezone set in APP_TIMEZONE and display events with the correct time without requiring manual adjustments.

How to reproduce the bug

Steps to reproduce:

1.  Set the timezone in the .env file to 'America/Guatemala'.
2.  Retrieve events from the calendar.
3.  Notice that the events are off by 6 hours.

Package Version

1.8

PHP Version

8.2

Laravel Version

11.27.2

Which operating systems does with happen with?

macOS

Notes

No response

lukas-frey commented 1 month ago

The underlying calendar package doesn't support timezones.

You need to handle the timezone conversion yourself on the server side, as answered here.