[Solved] Time code according to country's time zone?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

[Solved] Time code according to country's time zone?

#1 Post by Nanahs »

Why do I always have those crazy/difficult ideas? :oops: :lol:

I'm using this code to make the character Jhon say "good morning", "good afternoon", "good evening", "good night".

Code: Select all

    if hour in [6,7,8,9,10,11]:
        jump jhonmorning
        
    if hour in [12, 13, 14, 15, 16]:
        jump jhonafternoon

    if hour in [17, 18, 19]:
        jump jhonevening

    if hour in [20, 21, 22, 23, 00, 1, 2, 3, 4, 5]:
        jump jhonnight


This "uses" the time of my pc/phone.

Is it possible to use a certain country's time?

For example. Let's just say that Jhon is in Paris. And I wanted him to say "it's morning here", "it's night here", according to the real time in Paris.

Is it possible? To get this "hour" from a certain country?
And if it is, would you need to be connected to the internet to make it work?

Just a curiosity I have.

ps: something like https://stackoverflow.com/questions/258 ... t-timezone

Thanks.
Last edited by Nanahs on Sun Feb 10, 2019 5:06 pm, edited 1 time in total.

User avatar
Karl_C
Veteran
Posts: 232
Joined: Sun Mar 31, 2013 6:18 am
Contact:

Re: Time code according to country's time zone?

#2 Post by Karl_C »

Your link has the answer:

Code: Select all

import pytz

tz = pytz.timezone('Europe/Paris')
paris_now = datetime.now(tz)

User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: Time code according to country's time zone?

#3 Post by Nanahs »

Karl_C wrote: Sat Feb 09, 2019 1:31 am Your link has the answer:

Code: Select all

import pytz

tz = pytz.timezone('Europe/Paris')
paris_now = datetime.now(tz)
I tried it, but it didn't work. Maybe it did something wrong in the way hah
But, thank you! I'll try it again :)

Post Reply

Who is online

Users browsing this forum: Google [Bot]