real Time Clock - Am and PM, not militarry!

Learn how to make certain types of games and use gameEditor.

Re: real Time Clock - Am and PM, not militarry!

Postby Bee-Ant » Wed Oct 07, 2009 8:42 am

Yeah...DST you knock it !
User avatar
Bee-Ant
 
Posts: 3695
Joined: Wed Apr 11, 2007 12:05 pm
Location: Can bee found antywhere
Score: 209 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Hblade » Tue Oct 13, 2009 12:59 am

O.o
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4379
Joined: Fri Dec 08, 2006 11:14 pm
Score: 169 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Kalladdolf » Sat Oct 17, 2009 4:10 pm

LOL.
Also: Monkeys!
User avatar
Kalladdolf
 
Posts: 2428
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 119 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Bee-Ant » Sat Oct 17, 2009 5:36 pm

Hohoho, just kidding HBlade :P
User avatar
Bee-Ant
 
Posts: 3695
Joined: Wed Apr 11, 2007 12:05 pm
Location: Can bee found antywhere
Score: 209 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Hblade » Tue Oct 20, 2009 3:46 pm

My ducky says hi O.o
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4379
Joined: Fri Dec 08, 2006 11:14 pm
Score: 169 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Wertyboy » Fri May 27, 2011 3:05 pm

is this topic still alive?
i want to ask
if 22:04, it is 10:4PM, i want to make it like 10:04 PM
How?
(Im using the fixed code anyway)
left... well... kinda
User avatar
Wertyboy
 
Posts: 525
Joined: Tue Jun 15, 2010 12:38 pm
Location: HCM City, Vietnam
Score: 42 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Hblade » Fri May 27, 2011 7:07 pm

dunno, sorry :/ You could try if sec<10 then have it strcat(text, "0"); before finishing the seconds
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4379
Joined: Fri Dec 08, 2006 11:14 pm
Score: 169 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Game A Gogo » Fri May 27, 2011 8:22 pm

at one point in the scripts, you have this part of code sprintf(text, "%d:%d:%d AM", Hour, u.min, u.sec);
as you can see the %d is to display a double value (Hence the d), you could also use i (I'd recommend it) for integer values "%i"
But how to add padding zeros? easy like eating a pie you like! sprintf comes with more formatting options, replace the "%d" to "%02i", the 0 indicates that it should pad with 0's (If you leave it out, it will pad with spaces) and the 2 indicates how many digits you want to appear minimum.
So...
%02i could give out: "04"
%2i could give out: " 4"
%04i could give out: "0004"
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3464
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby skydereign » Fri May 27, 2011 8:28 pm

Just as an extra option, you can use this (I prefer it at least). It's pretty much just like Bee-Ant's, but it adjusts for a few things.
Code: Select all
stTime t = getTime();
sprintf(text, "%02d:%02d:%02d %s", t.hour%12, t.min, t.sec, (t.hour>11 ? "PM" : "AM"));


Oh, and there is no difference between using d or i. They both represent an int.
User avatar
skydereign
 
Posts: 3463
Joined: Mon Jul 28, 2008 8:29 am
Score: 571 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Hblade » Fri May 27, 2011 8:59 pm

Sky
Your intelligence amazes me. You seem to always have a new and better way of doing things and so I wanna say congrats on being able to do this :P
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4379
Joined: Fri Dec 08, 2006 11:14 pm
Score: 169 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Wertyboy » Sat May 28, 2011 2:54 am

Game A Gogo wrote:at one point in the scripts, you have this part of code sprintf(text, "%d:%d:%d AM", Hour, u.min, u.sec);
as you can see the %d is to display a double value (Hence the d), you could also use i (I'd recommend it) for integer values "%i"
But how to add padding zeros? easy like eating a pie you like! sprintf comes with more formatting options, replace the "%d" to "%02i", the 0 indicates that it should pad with 0's (If you leave it out, it will pad with spaces) and the 2 indicates how many digits you want to appear minimum.
So...
%02i could give out: "04"
%2i could give out: " 4"
%04i could give out: "0004"

thx, so what about when 01:00 PM, i want it to: 13:00 (Removed AM & PM)
left... well... kinda
User avatar
Wertyboy
 
Posts: 525
Joined: Tue Jun 15, 2010 12:38 pm
Location: HCM City, Vietnam
Score: 42 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby MrJolteon » Sat May 28, 2011 5:33 am

Wertyboy wrote:
Game A Gogo wrote:at one point in the scripts, you have this part of code sprintf(text, "%d:%d:%d AM", Hour, u.min, u.sec);
as you can see the %d is to display a double value (Hence the d), you could also use i (I'd recommend it) for integer values "%i"
But how to add padding zeros? easy like eating a pie you like! sprintf comes with more formatting options, replace the "%d" to "%02i", the 0 indicates that it should pad with 0's (If you leave it out, it will pad with spaces) and the 2 indicates how many digits you want to appear minimum.
So...
%02i could give out: "04"
%2i could give out: " 4"
%04i could give out: "0004"

thx, so what about when 01:00 PM, i want it to: 13:00 (Removed AM & PM)

Here's a code I made a while back(Requires 4 text actors: Hours, minutes, seconds and : :, all codes goes into the : : actor. )
viewtopic.php?f=5&t=6667

Here's an example:
http://dl.dropbox.com/u/6984849/Clock%2 ... xample.zip
Owner of the #GameEditor IRC channel at esper.net
User avatar
MrJolteon
 
Posts: 1926
Joined: Sat Aug 09, 2008 3:25 pm
Location: Fifth Layer
Score: 75 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Hblade » Sun May 29, 2011 1:27 pm

:D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4379
Joined: Fri Dec 08, 2006 11:14 pm
Score: 169 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby EvanBlack » Sun Oct 09, 2011 8:23 am

More clocks! XD I want to see some crazy stuff.

How much can you do with a clock anyway? I mean generally speaking you have a Digital, Analog, and Military. Can anyone make a sun dial?
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby MrJolteon » Sun Oct 09, 2011 3:28 pm

I guess, with enough coding skills
Owner of the #GameEditor IRC channel at esper.net
User avatar
MrJolteon
 
Posts: 1926
Joined: Sat Aug 09, 2008 3:25 pm
Location: Fifth Layer
Score: 75 Give a positive score

PreviousNext

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest