time shorthand convertor

Mark Wieder mwieder at ahsoftware.net
Thu Jul 27 17:58:53 EDT 2006


Josh-

Thursday, July 27, 2006, 11:06:29 AM, you wrote:

Cute. I couldn't resist fiddling with it a bit.

ON convertTime
  local t
  local ampm
  local t2
  
  put the text of the target into t
  put "PM" into ampm
  REPEAT for each char c in t
    IF c is a number THEN
      put c after t2
    ELSE IF c is "a" THEN
      put "AM" into ampm
    END IF
  END REPEAT
   
  SWITCH the number of chars in t2
    CASE 1
    CASE 2
      put ":00" after t2
      break
    CASE 3
    CASE 4
      put ":" before char -2 of t2
      break
  END SWITCH
  put space & ampm after t2
  put t2 into the target
END convertTime

Now for homework, put in some date validation (try entering 789).

(we had some plumbing work done on our house in October of 2003, and
the plumber wrote a shorthand inscription noting that it was finished
in 103, which still boggles my mind every time I think about it...)

-- 
-Mark Wieder
 mwieder at ahsoftware.net




More information about the use-livecode mailing list