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

Today's date ignores local_timezone #836

Open
ryannjohnson opened this issue Jan 22, 2019 · 6 comments · May be fixed by #1316
Open

Today's date ignores local_timezone #836

ryannjohnson opened this issue Jan 22, 2019 · 6 comments · May be fixed by #1316

Comments

@ryannjohnson
Copy link
Contributor

My config has the following:

[locale]
default_timezone = America/Los_Angeles
local_timezone = America/Los_Angeles

My computer's timezone is set to UTC. It's displaying 2019-01-22 06:30:00 right now.

In Los Angeles, the time is currently 2019-01-21 22:30:00.

When I run khal, this is what I get:

$ khal
    Su Mo Tu We Th Fr Sa     Today, 2019-01-22
Jan 30 31  1  2  3  4  5     17:00-20:00 Meeting
     6  7  8  9 10 11 12     Tomorrow, 2019-01-23
    13 14 15 16 17 18 19     Thursday, 2019-01-24
    20 21 22 23 24 25 26     17:00-20:00 Meeting
Feb 27 28 29 30 31  1  2     Friday, 2019-01-25
     3  4  5  6  7  8  9     16:30-18:30 Meeting
    10 11 12 13 14 15 16     Saturday, 2019-01-26
    17 18 19 20 21 22 23     
Mar 24 25 26 27 28  1  2     
     3  4  5  6  7  8  9     
    10 11 12 13 14 15 16     
    17 18 19 20 21 22 23     
    24 25 26 27 28 29 30     
Apr 31  1  2  3  4  5  6

I expect Today, 2019-01-22 to be the 21st of January, not the 22nd of January.

The event times show up correctly, but they are truncated if their day is not shown.

$ khal calendar 2019-01-21
    Su Mo Tu We Th Fr Sa     Monday, 2019-01-21
Jan 30 31  1  2  3  4  5     23:00-24:00 Today!
     6  7  8  9 10 11 12     Today, 2019-01-22
    13 14 15 16 17 18 19     17:00-20:00 Meeting
    20 21 22 23 24 25 26     Tomorrow, 2019-01-23
Feb 27 28 29 30 31  1  2     Thursday, 2019-01-24
     3  4  5  6  7  8  9     17:00-20:00 Meeting
    10 11 12 13 14 15 16     Friday, 2019-01-25
    17 18 19 20 21 22 23     16:30-18:30 Meeting
Mar 24 25 26 27 28  1  2     
     3  4  5  6  7  8  9     
    10 11 12 13 14 15 16     
    17 18 19 20 21 22 23     
    24 25 26 27 28 29 30     
Apr 31  1  2  3  4  5  6

This happens for me both via pip install khal and from running master.

Is this something fixable from my configuration or is it worth me making a pull request for?

@geier
Copy link
Member

geier commented Feb 12, 2019

Thanks for having a look, I don't think this a fixable via configuration, but a proper bug.

@geier
Copy link
Member

geier commented Feb 12, 2019

This issue probably needs to be fixed for khal and ikhal. The relevant functions probably are:

def construct_daynames(date_):

and

def relative_day(self, day, dtformat):

@geier
Copy link
Member

geier commented Feb 12, 2019

If you find the time, please do send a PR.

@geier
Copy link
Member

geier commented Oct 31, 2023

While I'm only getting to this nearly 5 years later, I cannot reproduce this

I can reproduce this, the behavior is just more consistently wrong nowadays.

@geier
Copy link
Member

geier commented Oct 31, 2023

Root of the issue seems to be that we compare against date.today() which is using the system's time, not the local one. Probably same issue as #849

@geier
Copy link
Member

geier commented Oct 31, 2023

We probably need to replace every call to dt.date.today() with something like this:

today = pytz.UTC.localize(dt.datetime.utcnow()).astimezone(local_timezone).date()

geier added a commit that referenced this issue Nov 1, 2023
geier added a commit that referenced this issue Nov 3, 2023
geier added a commit that referenced this issue Apr 14, 2024
geier added a commit that referenced this issue Apr 14, 2024
geier added a commit that referenced this issue Apr 14, 2024
@geier geier linked a pull request Apr 14, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants