Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Military Time
Message
 
 
To
01/08/2007 15:37:55
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01245247
Message ID:
01245252
Views:
20
>How can I convert the following to non-military time? And yes, before the jokes start, the "13:45" is a value in an array. I can't just retype it to "1:45" instead. Thanks!
>
>
>(RIGHT( "0" + ALLTRIM( "13:45" ), 5 ))
>
function ConvertToNonMilitary
lparameters tcTime
* No parameter checking yet
local lnHours, lcMins

lnHours = int(val(getwordnum(m.tcTime,1,':')))
lcMins = getwordnum(m.tcTime,2,':')

do case
  case m.tcTime = '24:00'
       lcConvert = '12:00 AM'

  case m.lnHours = 12
       lcConvert = m.tcTime + ' PM'

  case between(m.lnHours, 13,23)
   lcConvert = padl(m.lnHours - 12,2,'0') + ':' + m.lcMins + ' PM'

  otherwise
   lcConvert = padl(m.lnHours,2,'0') + ':' + m.lcMins + ' AM'
  endcase
return m.lcConvert
From the top of my head, not tested yet.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform