| View previous topic :: View next topic |
| Author |
Message |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Sun Dec 01, 2002 11:05 pm Post subject: 12 hour time |
|
|
How can I get the hour of the day (or night) in 12 hr. format?
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 |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sun Dec 01, 2002 11:25 pm Post subject: |
|
|
To get JUST the hour:
| Code: |
PARSE "%%hour", @datetime(h|am/pm)
INFO %%hour
|
Cheers, Mac  _________________ 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 |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Mon Dec 02, 2002 5:32 am Post subject: |
|
|
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 |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Mon Dec 02, 2002 8:58 am Post subject: |
|
|
Uh... did I misunderstand the question?
Cheers, Mac  _________________ 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 |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Mon Dec 02, 2002 8:12 pm Post subject: |
|
|
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?
-Garrett |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Mon Dec 02, 2002 9:17 pm Post subject: |
|
|
LOL
Help us out here FF...
Cheers, Mac  _________________ 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 |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Mon Dec 02, 2002 9:20 pm Post subject: |
|
|
They're both good examples..
Quit yer whinin  _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Mon Dec 02, 2002 9:26 pm Post subject: |
|
|
| SnarlingSheep wrote: | Quit yer whinin  |
LOL, quit yer snarlin' Sheep...
Cheers, Mac  _________________ 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 |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Mon Dec 02, 2002 10:27 pm Post subject: |
|
|
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  _________________ 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 |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Mon Dec 02, 2002 10:35 pm Post subject: |
|
|
Sorry if I was a bit vague with my question.
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.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Mon Dec 02, 2002 10:43 pm Post subject: |
|
|
Glad to hear it FF,
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...
Cheers, Mac  _________________ 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 |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Tue Dec 03, 2002 3:39 am Post subject: |
|
|
| 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!
-Garrett |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Dec 03, 2002 4:21 am Post subject: |
|
|
Hey Garrett,
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).
So it's not the same thing...
| 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  _________________ 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 |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Tue Dec 03, 2002 8:46 am Post subject: |
|
|
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".
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.
-Garrett |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Dec 03, 2002 9:27 am Post subject: |
|
|
| 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...
At least none of my clocks have ZERO hour numbers
(0 thru 24 - I guess that would be for 25 hour days?)...
Cheers, Mac  _________________ 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 |
|
 |
|