layer Posted January 3, 2005 Share Posted January 3, 2005 (edited) is there a way to specify weather it is AM or PM next to the @Hour etc macors?? EDIT: also, i am using @Hour -12... maybe that's why Jon made it army ime with no PM's and AM's 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 January 3, 2005 by layer FootbaG Link to comment Share on other sites More sharing options...
killaz219 Posted January 3, 2005 Share Posted January 3, 2005 you could do something like $hour = @HOUR If $hour > 12 Then $status = "PM" $hour = $hour - 12 Else $status = "AM" EndIf MsgBox( 0, "", "It is " & $hour & " " & $status) Link to comment Share on other sites More sharing options...
Coffee Posted January 3, 2005 Share Posted January 3, 2005 $hour = @HOURIf $hour > 12 Then $status = "PM" $hour = $hour - 12Else $status = "AM"EndIfMsgBox( 0, "", "It is " & $hour & " " & $status)careful as:If $hour > 12 Thenwill not give you "pm" for 12 noon.also the -12 gets you 0 for 12 noon, -10 for 2am etc. time is goofy to convertnot 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 More sharing options...
the_lord_mephy Posted January 3, 2005 Share Posted January 3, 2005 (edited) 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 convertnot 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"EndIfthat might work =\ Edited January 3, 2005 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 More sharing options...
Coffee Posted January 3, 2005 Share Posted January 3, 2005 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 redundantI 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 @hourthenElseIf @hour = 24 then $hour = @hour - 12 $status = "AM"needs to be switched out for a 00 alternativeand in my case to quit trying to confuse everyone including myselfSorry 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 More sharing options...
therks Posted January 3, 2005 Share Posted January 3, 2005 I always did it like this... $hour = @HOUR; $ampm = 'AM'; If $hour >= 12 Then $ampm = 'PM'; If $hour > 12 Then $hour = $hour - 12; EndIf ElseIf $hour = 0 Then $hour = 12; EndIf Just thought it looked neater. argumentum 1 My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
layer Posted January 3, 2005 Author Share Posted January 3, 2005 thanks guys but i think ill just stick with standard army time FootbaG Link to comment Share on other sites More sharing options...
Blue_Drache Posted January 3, 2005 Share Posted January 3, 2005 I find it easier to use the 24 hour clock, but not everyone lives in Europe, on a military base, or can do time math easily. Saunders has the best snippet, IMO. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now