Open kailashchoudhary11 opened 2 years ago
If this seems a valid issue, I would like to work on it!
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 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 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 😊
@Dilshan-H isntead of using
generatedOn = str(dt.now().astimezone(pytz.timezone('Asia/Colombo')))
can't we directly usegeneratedOn = str(dt.now().astimezone())
Won't this give the current timezone of the user? Just a doubt I read it here - GeeksforGeeksIf 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?
@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.
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)
I think the better way would be to send the timezone from the browser using js!
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)
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
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.
Currently the emails are being tracked base on the timezone "Asia/Colombo" Instead we can track it using the timezone of the user!