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

Tracking Email based on the user's timezone! #3

Open
kailashchoudhary11 opened this issue Oct 15, 2022 · 11 comments
Open

Tracking Email based on the user's timezone! #3

kailashchoudhary11 opened this issue Oct 15, 2022 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@kailashchoudhary11
Copy link
Contributor

Currently the emails are being tracked base on the timezone "Asia/Colombo" Instead we can track it using the timezone of the user!

@kailashchoudhary11
Copy link
Contributor Author

If this seems a valid issue, I would like to work on it!

@Dilshan-H
Copy link
Owner

At the moment, user has to manually edit routes.py to change their timezone. And it is documented within 'Installation' section of the readme.
But, more feasible and efficient way can be implemented here.
@kailashchoudhary11 you are welcome to propose your changes anytime 😊

@Dilshan-H Dilshan-H added the enhancement New feature or request label Oct 15, 2022
@saroshfarhan
Copy link

saroshfarhan commented Oct 15, 2022

@Dilshan-H isntead of using
generatedOn = str(dt.now().astimezone(pytz.timezone('Asia/Colombo')))

can't we directly use
generatedOn = str(dt.now().astimezone())

Won't this give the current timezone of the user? Just a doubt
I read it here - GeeksforGeeks

@Dilshan-H
Copy link
Owner

Dilshan-H commented Oct 15, 2022

@Dilshan-H isntead of using
generatedOn = str(dt.now().astimezone(pytz.timezone('Asia/Colombo')))

can't we directly use
generatedOn = str(dt.now().astimezone())

Won't this give the current timezone of the user? Just a doubt
I read it here - GeeksforGeeks

If you are planning to host the application in a local environment, this works just fine. But when it comes to remote servers they are maybe located in different timezones. That's why we need to pass timezone parameter specifically. That way we can get the datetime according to our local time zone.
Hope this clarifies you issue 😊

@saroshfarhan
Copy link

@Dilshan-H isntead of using
generatedOn = str(dt.now().astimezone(pytz.timezone('Asia/Colombo')))
can't we directly use
generatedOn = str(dt.now().astimezone())
Won't this give the current timezone of the user? Just a doubt
I read it here - GeeksforGeeks

If you are planning to host the application in a local environment, this works just fine. But when it comes to remote servers they are maybe located in different timezones. That's why we need to pass timezone parameter specifically. That way we can get the datetime according to our local time zone. Hope this clarifies you issue 😊

Aah, didn't think of it that way, you're absolutely right.
Just had one more doubt, do we really need to show the time of creation of thee tracker to the user? What purpose does that information serve and can we not use utc instead?

@Dilshan-H
Copy link
Owner

@saroshfarhan It's better to show that info as user can quickly refer their corresponding email at a later time. When there are lot of tracking links this might be useful in a way.
Also I'm hoping to implement a search functionality inside tracking link list dashboard. So, a user can search for tracking links that were generated in a specific date for example.

@Gamerited
Copy link

Hey @Dilshan-H,

We could import tzlocal and could get the local time? You can try this on a separate python file.

we would require tzlocal

pip3 install tzlocal

from datetime import datetime as dt
import pytz
from tzlocal import get_localzone


generatedOn = str(dt.now().astimezone(pytz.timezone(str(get_localzone()))))
print(generatedOn)

@kailashchoudhary11
Copy link
Contributor Author

I think the better way would be to send the timezone from the browser using js!

@Dilshan-H
Copy link
Owner

Dilshan-H commented Oct 16, 2022

I think the better way would be to send the timezone from the browser using js!

Actually that seems like a better way to achieve this.

Hey @Dilshan-H,

We could import tzlocal and could get the local time? You can try this on a separate python file.

we would require tzlocal

pip3 install tzlocal

from datetime import datetime as dt
import pytz
from tzlocal import get_localzone


generatedOn = str(dt.now().astimezone(pytz.timezone(str(get_localzone()))))
print(generatedOn)

It will produce the same issue as earlier isn't it? (When used in remote servers)

@kailashchoudhary11
Copy link
Contributor Author

I think the better way would be to send the timezone from the browser using js!

Actually that seems like a better way to achieve this.

So can you assign this to me

@Gamerited
Copy link

It will produce the same issue as earlier isn't it? (When used in remote servers)

It does only solve the backend time issue. Not when it runs on the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants