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

How to present correct times to users? #258

Open
hippylover opened this issue Jul 30, 2018 · 0 comments
Open

How to present correct times to users? #258

hippylover opened this issue Jul 30, 2018 · 0 comments

Comments

@hippylover
Copy link

hippylover commented Jul 30, 2018

Hello, I have made a script i want to share with users located around the world. The script get's times from a server feeding it in UTC this format(string):

'2018-07-30T13:20:39.943Z'

There's 2 display settings in my script. One that shows human-friendly output and one that shows the date and time. When i do:

pendulum.parse(data['datetime'], tz=pendulum.local_timezone()).diff_for_humans()

The time comes out correct(at least on my machine). That is to say, if something happened right now and let's say my local clock here in oslo is 18:45 then the server will send a signal to my script saying it happened 16:45 and the diff_for_humans() function converts it to for ex "1 second ago" and i am happy.

However, if the user chooses to not have "human friendly" datetime display the time with this command:

pendulum.parse(x['datetime'], tz=pendulum.local_timezone()).to_datetime_string()

It will show the time as 16:45 which is not what i want...

How do i make pendulum give the correct datetime even if the diff_for_humans() function is not ran? If i can avoid having to ask which timezone the user is in in the script, that would also be best.

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

No branches or pull requests

1 participant