forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


12 hour time

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Dec 01, 2002 11:05 pm    Post subject: 12 hour time Reply with quote

How can I get the hour of the day (or night) in 12 hr. format? Confused
This simply won't work well with 24-hour time:

Code:
%a = @datetime(h)
%b = @sum(%a,5)
repeat
wait 5
if @equal(%b,@datetime(h))
rem Do something
end
until
:close
exit

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Dec 01, 2002 11:25 pm    Post subject: Reply with quote

To get JUST the hour:

Code:

PARSE "%%hour", @datetime(h|am/pm)
INFO %%hour


Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Mon Dec 02, 2002 5:32 am    Post subject: Reply with quote

I used something like this myself a few years back.. Tried finding the
original code so I could be sure, but couldn't. I think this is correct
code for what you need. If not, at least it gives you the idea.

-Garrett

Code:

If @greater(%b,12)
  REM - PM
  %b = @fsub(%b,12)
  If @equal(%b,0)
    %b = 12
  End
Else
  REM - AM
  If @equal(%b,0)
    %b = 12
  End
End
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Mon Dec 02, 2002 8:58 am    Post subject: Reply with quote

Uh... did I misunderstand the question? Confused

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Mon Dec 02, 2002 8:12 pm    Post subject: Reply with quote

Gees Mac, now you've got me wondering.... I'm not sure if he wanted
just the @datetime() format for 12 hour time, or if he wanted a routine
to convert 24 hour time to 12 hour time.

When does the hurting stop? Wink

-Garrett
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Mon Dec 02, 2002 9:17 pm    Post subject: Reply with quote

LOL Laughing

Help us out here FF... Embarassed

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Mon Dec 02, 2002 9:20 pm    Post subject: Reply with quote

They're both good examples..
Quit yer whinin Wink

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Mon Dec 02, 2002 9:26 pm    Post subject: Reply with quote

SnarlingSheep wrote:
Quit yer whinin Wink

LOL, quit yer snarlin' Sheep... Razz Laughing

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Mon Dec 02, 2002 10:27 pm    Post subject: Reply with quote

Since Garrett's example checks an IF twice either way,
there's really no need for the ELSE. This should also work
for time subtraction...
Code:

if @greater(%b, 12)
   %b = @diff(%b, 12)
end
if @greater(1, %b)
   %b = @sum(12, %b)
end

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Mon Dec 02, 2002 10:35 pm    Post subject: Reply with quote

Sorry if I was a bit vague with my question. Embarassed

Mac, your example was sufficient for my needs, I just needed to know the
hour and did not want to have to deal with 24-hour time.

The other examples were a help too anyway. Very Happy

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Mon Dec 02, 2002 10:43 pm    Post subject: Reply with quote

Glad to hear it FF, Wink

I changed this line in the last example about the time
you posted:

%b = @sum(12, %b)

I originally used @diff(), which didn't play nice
with negative numbers... Wink

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Tue Dec 03, 2002 3:39 am    Post subject: Reply with quote

Mac wrote:

Code:

if @greater(%b, 12)
   %b = @diff(%b, 12)
end
if @greater(1, %b)
   %b = @sum(12, %b)
end


Or like this:

Code:
If @equal(%b,0)
  %b = 12
End
If @greater(%b,12)
  %b = @fsub(%b,12)
End


Ok, now that we've started playing this, let's see how many ways we
can write the same thing! Laughing

-Garrett
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Tue Dec 03, 2002 4:21 am    Post subject: Reply with quote

Hey Garrett, Smile

The purpose of my changing "if @equal(%b, 0)"
was to cover both adding and subtracting hours
from the time (in case ya get a negative number). Wink

So it's not the same thing... Razz Laughing
Code:

%b = -3
if @greater(%b, 12)
   %b = @diff(%b, 12)
end
if @greater(1, %b)
   %b = @sum(12, %b)
end
INFO %b

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Tue Dec 03, 2002 8:46 am    Post subject: Reply with quote

May I ask how you would get a negative number when the numbers will
be from 0 through 24??? I don't know about you, but I've never had a
clock tell me that it was "-3:00". Laughing

You sure are right, it's not the same thing. You're clock must be as old
as Windows 95!!! Hehehehehehee.... Ok, I'm just givin' ya a bad time
on that one. Very Happy

-Garrett
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Tue Dec 03, 2002 9:27 am    Post subject: Reply with quote

Garrett wrote:
May I ask how you would get a negative number when the numbers will be from 0 through 24???

LOL, ya old geezer... Razz Laughing

At least none of my clocks have ZERO hour numbers
(0 thru 24 - I guess that would be for 25 hour days?)... Shocked

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group