Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: PsYcHiC on July 01, 2003, 11:44 AM

Title: How do you add the time? [TT:TT:TTAM]
Post by: PsYcHiC on July 01, 2003, 11:44 AM
How do you make those in front of the text you send? I mean the right time, not the [HH:MM:SS] like [03:23:53 AM]?  Any help would be appreciated.

HH = Hours
MM = Minutes
SS = Seconds
Title: What language?
Post by: Kp on July 01, 2003, 01:36 PM
If you're using C/C++ (which I somewhat doubt), consult strftime documentation.
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: c0ol on July 01, 2003, 02:07 PM
is this really bot related, i mean seriously this is like simple string manipulation.
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: iago on July 01, 2003, 02:48 PM
char *GetTime(char Buffer[12])
{
   // Get the time:
   long currtime = time(NULL);
   tm *Time = localtime(&currtime);
   sprintf(Buffer, "%02d:%02d:%02d%s", (Time->tm_hour <= 12) ? Time->tm_hour : (Time->tm_hour - 12), Time->tm_min, Time->tm_sec, Time->tm_hour > 12 ? "PM" : "AM");

   return Buffer;
}


That'll return the 12-hour-clock time.  If you want a 24-hours clock, use this:
char *GetTime(char Buffer[10])
{
   // Get the time:
   long currtime = time(NULL);
   tm *Time = localtime(&currtime);
   sprintf(Buffer, "%02d:%02d:%02d",  Time->tm_hour, Time->tm_min, Time->tm_sec);

   return Buffer;
}


And to use these, just use a sprintf to get it into a buffer
char TimeBuf[12];
sprintf("%s <%s> %s\n", GetTime(TimeBuf), sender, message);
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: DarkMinion on July 01, 2003, 04:21 PM

void TimeStamp(char *szBuf)
{
   SYSTEMTIME st;
   GetLocalTime(&st);
   sprintf(szBuf, "[%02i:%02i:%02i]  ", st.wHour, st.wMinute, st.wSecond);
}


:P
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: Yoni on July 01, 2003, 05:10 PM
12-hour notation sucks.
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: DarkMinion on July 01, 2003, 07:29 PM
Is not 12 hour!
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: Lenny on July 01, 2003, 11:16 PM
How about 24 hr timestamps is vb?
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: iago on July 01, 2003, 11:26 PM
My second one is 24 hour
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: UserLoser on July 01, 2003, 11:36 PM
Format(Time, "hh:mm:ss")
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: Lenny on July 02, 2003, 12:07 AM
Would I be correct in saying that I would need a timer to add onto Format(Time, "hh:mm:ss") so it changes?
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: Grok on July 02, 2003, 06:13 AM
For 24-hour time, use:

Format(Time, "HH:mm:ss")
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: Lenny on July 02, 2003, 11:23 PM
I mean for a clock......
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: Hazard on July 03, 2003, 07:50 AM
-1 to Lenny. Stop asking the same question over and over and not reading the answers you get.

!~!HaZaRD!~!
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: Lenny on July 03, 2003, 03:47 PM
I havent been asking the same question...Im asking how would you make a clock not a TIMESTAMP
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: PsYcHiC on July 03, 2003, 10:48 PM
Quote from: Lenny on July 03, 2003, 03:47 PM
I havent been asking the same question...Im asking how would you make a clock not a TIMESTAMP
See that has nothing to do with VB, go buy some hardware tools and "Make" your "Clock".
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: Lenny on July 03, 2003, 11:05 PM
PsYcHiC, I really hope that you are joking........especially since you started the thread.....

Once again back to the subject.......Exactly how would I make a clock in visual basic (example: The thing that most people have in the bottom right corner of the screen)

I hope my question is clear enough now
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: PsYcHiC on July 03, 2003, 11:16 PM
Quote from: Lenny on July 03, 2003, 11:05 PM
PsYcHiC, I really hope that you are joking........especially since you started the thread.....

Once again back to the subject.......Exactly how would I make a clock in visual basic (example: The thing that most people have in the bottom right corner of the screen)

I hope my question is clear enough now

#1 for Lenny, Yes I was joking.
#2 for DarkMinion, its something called a "joke".
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: Camel on July 04, 2003, 01:53 AM
Lenny, a clock is simply a timestamp that updates itself. Use a timer.
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: Grok on July 04, 2003, 03:01 AM
On the Visual Basic menu, choose Project | Components  (Control-T).  Check the box for "Microsoft Windows Common Controls 6.0 (SP4)" and click OK.

In the toolbox, double-click a status bar icon.  Right click the new status bar and choose properties.  On the "Panels" tab, change the Style property to "5-sbrTime" and click OK.

Run the project.  The time will be displayed on the form's status bar.
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: Lenny on July 04, 2003, 07:56 PM
Thank you.....
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: gosu on July 08, 2003, 09:49 PM
this might be kinda late but you can have a timer and a label or textbox.  within the timer, put label1.caption = time  or text1.text = time

and if you want date just replace time with date
Title: Re:How do you add the time? [TT:TT:TTAM]
Post by: blinkdude on July 11, 2003, 04:29 PM
use the ez way :)  uses your windos time :)


rtbAdd " [" & time & "]" & " or w/e u want here! "