••••i am trying to build a clock using python where the clock is about 1/2 an earth second, it would have 11 seconds in a minute, it would have 5 minutes in an hour, and it would have 3 hours in a day. it would also have 3 months per year, each month would be 5, 3 and 4 days respectively. And its current year now is 9977. it would have 2 modes, a fast mode and a regular mode.
I need to know how to start this, how to defined the variables and functions.
Can anyone please help.

Recommended Answers

All 7 Replies

You can use the time library using import time.
You are going to want to use something along the lines of time.sleep(Seconds)
http://docs.python.org/library/time.html

I don't really understand what you are talking about with a hour being 5 minutes in a hour and 11 seconds in a minute.

Think first. Think about what you said. And put into the code. Simple... Ok, I'm actually going to give you a hand. So you want, 11 seconds in a minute, 5 minutes in an hour, 3 hours in a day and 3 months per year, and I don't know what you mean by, "each month would be 5, 3 and 4 days respectively". Anyway, now you obviously read what tbone2sk said, and you obviously already know that time.sleep counts in seconds. So, lets do a bit of maths revision:

oneMinute = 11 seconds
oneHour = 60(One Minute) * 5 = 300 seconds
oneDay = 300(One Hour) * 3 = 900 seconds
oneMonth = 900(One Day) * 30 = 27000 seconds
threeMonths = 27000(One Month) * 3 = 81000 seconds

This looks well complicated, and well it is complicated, why? Why is it so complicated? Why do you need it for? Anyway. I basically gave you the answer, at least I tried. Nevertheless, I am in a good mood, so lets do it together. First you have to import the module/library (import time), then you basically need to put my calculations variables. For example:

import time
oneMinute = time.sleep(11)

And that's basically it. You get what I mean, well I probably did not answer what you were looking for, but that's because you could be a little bit more precise, but at least I might give a new idea, for what ever weird thing you're doing. I will be happy in helping you, if the answer that I gave you, was the kind of answer that did not help you. Hope it helps, and good luck, because you will need. Dan08

I bet he's making a game which takes place on a different planet :D

_

i think is what he meant was instead of months being 30,28, and 31, he replaces with 5, 4 qand 3 on respective months

import time
minc=0
minh=0
def onesecond():

time.sleep(0.5)

def oneminute():
minc=0
while minc<11:
minc+=1
onesecond()
print("Second: "+str(minc))

def onehour():
minh=0
while minh<5:
minh+=1
oneminute()
print("Minute: "+str(minh))

def oneday():
mind=0
while mind<3:
mind+=1
onehour()
print("Day: "+str(mind))
def onemonth():
minm=0
while minm<4:
minm+=1
oneday()
print("Month: "+str(minm))
def oneyear():
miny=0
while miny<3:
miny+=1
onemonth()
print("Year: "+str(miny))

oneyear()

I think you are after more like this, just change in your own units and take out jump from midnight to next morning 5 o'clock if you want. Two speeds of advancing the time you can best deal by multiple increases of time per clock tick, in this code the advance is one hour per tick.

Re: Managing Date and Time change in text adventure

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.