anufrievroman / calcure

Modern TUI calendar and task manager with minimal and customizable UI.
https://anufrievroman.gitbook.io/calcure
MIT License
1.56k stars 45 forks source link

Use locale's Time Zone when provided #43

Closed nfultz closed 11 months ago

nfultz commented 1 year ago

I noticed that the calendar doesn't shift according to the locale's time zone, eg no difference when I launch as

TZ=America/Los_Angeles calcure 

Compare vs other cli tools:

(venv) calcure$date
Thu 23 Feb 22:06:31 UTC 2023
(venv) calcure$TZ=America/Los_Angeles date
Thu 23 Feb 14:06:34 PST 2023
anufrievroman commented 1 year ago

Yes, so far it doesn't care about timezones. I mean, for native calcure events there is no concept of "time" in calcure, only dates, so the "hours" are just text inside the title. However, I see that with .ics files it is a problem.

So, ideally, if in ics event the time is not "all day" we should try reading the timezone if provided, also read local timezone, and correct the time and date accordingly, right?

nfultz commented 1 year ago

So, ideally, if in ics event the time is not "all day" we should try reading the timezone if provided, also read local timezone, and correct the time and date accordingly, right?

I think that's a reasonable goal. At the minimum, I would want to adjust the day - UTC midnight is 4pm in my timezone, so evening events are showing up in the wrong box in the calendar.

euglevi commented 1 year ago

Can I ask if there are news on this issue? This is literally the only thing preventing me to use calcure, which I find a great tool!

anufrievroman commented 1 year ago

Hi, sorry for the delay. The problem is that it's more complex than I thought. I discovered as few issues actually: 1) ics library does not read the timezone, so I need to find a workaround to read it. 2) ics library (incorrectly) assumes that everything is in UTC. I guess that's what @nfultz meant above. This is a bug and should be fixed first. 3) Different calendars write their time zone differently, it seems. So, I'll need to investigate how to convert labels like "Asia/Tokyo" into actual hours value.

anufrievroman commented 1 year ago

Okay, I at least fixed db8897db5c9dab4b51c6a124bc46071ebc57c288 the bug when the time was converted to UTC time and shown as such. This was the bug of ics library (that exists for many years), which I didn't realize existed. Now, if you stay in one timezone and make events in this timezone everything should work. Please update and test the version 1.9.5 from PyPi:

pipx upgrade calcure

Especially if you live in a negative timezone, like in the USA, please let me know if that works. Next step is to read the provided timezone somehow and correct time accordingly.

euglevi commented 1 year ago

Thanks it is indeed much better this way! I can still see problems with timezones, but that solved most of the issues. By the way, I live in Italy.

anufrievroman commented 11 months ago

This issue seems to be resolved, and now all timezones seem to convert to local timezones as expected. Please try to install the current main branch to test:

pipx install git+https://github.com/anufrievroman/calcure
euglevi commented 11 months ago

I have tried and I confirm that, so far, the timezones seem to be correctly taken into consideration.

anufrievroman commented 11 months ago

Okay, this seems to fully work now, so I'll close this issue.