Jump to content

@Hour etc... how bout PM and AM?


layer
 Share

Recommended Posts

is there a way to specify weather it is AM or PM next to the @Hour etc macors?? :D

EDIT: also, i am using @Hour -12... maybe that's why Jon made it army ime with no PM's and AM's :idiot::lol: maybe i can just use the regular army time... when i realease my small, but i would think, pretty useful script, you can adjust it to your likings...

Edited by layer
FootbaG
Link to comment
Share on other sites

$hour = @HOUR

If $hour > 12 Then

  $status = "PM"

  $hour = $hour - 12

Else

  $status = "AM"

EndIf

MsgBox( 0, "", "It is " & $hour & " " & $status)

careful as:

If $hour > 12 Then

will not give you "pm" for 12 noon.

also the -12 gets you 0 for 12 noon, -10 for 2am etc. time is goofy to convert

not pointing out mistakes more of observations while playing with the time myself.

Here is some super bloated select/case code to get it working while trying to show what I mean.

Maybe this can be broken down to a udf and cleaned up of course for bulk.

$var = @HOUR
$cleanup = StringTrimLeft ($var, 1)

Select
;case @hour =12 keep 12 and put pm
case $var = 12 
msgbox(0, "12 hour time with am/pm", 'The time is ' & @hour & ':' & @MIN & "pm") 

case $var = 24;then -12 and put am
msgbox(0, "12 hour time with am/pm", 'The time is ' & $get12hour & ':' & @MIN & "am")

;case @hour = 12 (am)
case $var = 00 
msgbox(0, "12 hour time with am/pm", 'The time is ' & "12" & ':' & @MIN & "am")

;case 1,2,3,4,5,6,7,8,9 then keep @hour, strip out the first 0, and make am
case $var = 1 Or $var = 2 Or $var = 3 Or $var = 4 Or $var = 5 Or $var = 6  Or $var = 7 _
Or $var = 8 Or $var = 9
msgbox(0, "12 hour time with am/pm", 'The time is ' & $cleanup & ':' & @MIN & "am")

; case 10,11 keep @hour and put am
case $var = 10 Or $var = 11 
msgbox(0, "12 hour time with am/pm", 'The time is ' & @hour & ':' & @MIN & "am")

;case 13,14,15,16,17,18,19,20,21,22,23 then take -12 from @hour and make pm
case $var = 13 Or $var = 14 Or $var = 15 Or $var = 16 Or $var = 17 Or $var = 18  Or $var = 19 _
Or $var = 20 Or $var = 21 Or $var = 22 Or $var = 23  
   msgbox(0, "12 hour time with am/pm", 'The time is ' & $get12hour & ':' & @MIN & "pm")
EndSelect
Link to comment
Share on other sites

will not give you "pm" for 12 noon.

also the -12 gets you 0 for 12 noon, -10 for 2am etc. time is goofy to convert

not pointing out mistakes more of observations while playing with the time myself.

-12 wouldn't give him 0 for noon because 12 isn't > than 12, nor the other thing you said, everything works except you'd have 12 AM for noon and 12 PM for midnight.

If @hour > 12 then

$hour = @hour - 12

$status = "PM"

ElseIf @hour = 12 then

$status = "PM"

ElseIf @hour = 24 then

$hour = @hour - 12

$status = "AM"

Else

$status = "AM"

EndIf

that might work =\

Edited by the_lord_mephy
My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]
Link to comment
Share on other sites

I guess I worded it kind of wierd, the case 24 is only there for shits

and giggles really as there is no 24. (2400 hours)

12 noon = 12pm = 12 military time (1200 literally)

12 midnight = 12am = 00 (0000 literally)

my example should work although the case 24 is redundant

I guess what I meant was in killa's case

if it was 12 noon(pm) it would return as 12 am

$hour = @HOUR
If $hour > 12 Then
   $status = "PM"
   $hour = $hour - 12
Else
   $status = "AM"
EndIf

MsgBox( 0, "", "It is " & $hour & " " & $status)

and in your case just the opposite, if it is 12 midnight or 00 returned by @hour

then

ElseIf @hour = 24 then
$hour = @hour - 12
$status = "AM"

needs to be switched out for a 00 alternative

and in my case to quit trying to confuse everyone including myself

Sorry my comenting job was very subpar and probably caused way too much confusion, I need to learn to multitask.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...