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

Is the "in the future" calculation correct? #1161

Closed
ralsina opened this issue Mar 23, 2014 · 6 comments
Closed

Is the "in the future" calculation correct? #1161

ralsina opened this issue Mar 23, 2014 · 6 comments

Comments

@ralsina
Copy link
Member

ralsina commented Mar 23, 2014

What we are doing now is: we are comparing the post's date (with the TZ expressed in the date or in conf.py) against the current naive datetime with the TZ from conf.py applied.

I suspect it would make more sense to use a non-naive now() with the system's current TZ?

@Kwpolska
Copy link
Member

the system's current TZ

We don’t know that. And we don’t need to, as having an aware post date and an aware now(UTC) is enough (as the timezone magic will take care of that)

@ralsina
Copy link
Member Author

ralsina commented Mar 24, 2014

Yes we do know it, dateutil.tz.tzlocal() gives you the current TZ

@Kwpolska
Copy link
Member

Sorry, I’m not well-versed in dateutil, and did not know this. Sure thing — it does get the current TZ, from time.(time|alt)zone, and also handles DST well enough.

But still, we don’t really need the current timezone for this.

@ralsina
Copy link
Member Author

ralsina commented Mar 24, 2014

If we use the conf.py TZ then move east, you will create every new post in the future, because it will combine the naive "now" with the conf.py TZ :-)

@Kwpolska
Copy link
Member

So let’s not do naïve: let’s do UTC, and then it will combine aware UTC now and aware TZ — which will take care of itself.

Besides, one cannot compare aware and naïve date-times.

@ralsina
Copy link
Member Author

ralsina commented Mar 25, 2014

We are not comparing naive datetimes with non-naive ones, we are taking a naive one taken from the system clock, and blindly assigning a TZ that's not the system clock's to it. I'll propose a branch to "do the right thing".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants