Here is an interesting handler so that a user can enter a time in a field in a "shorthand" and get a full, properly formatted date out of it.

Here are some examples:

enter this = get this

1 = 1:00 PM
12 = 12:00 PM
123 = 1:23 PM
1234 = 12:34 PM

add an "a" at the end for am, like:

1a = 1:00 AM

We have been using this for a few days and everyone really likes it, it seems intuitive and faster than any other method of entering a time.



field script:

    ON enterInField
        convertTime
    END enterInField

    ON returnInField
        convertTime
    END returnInField

    ON closeField
        convertTime
    END closeField


put this somewhere in the message path:

    ON convertTime
        put the text of the target into t
        IF (char -1 to -2 of t = "am") OR (char -1 of t = "a") THEN
            put "AM" into ampm
        ELSE
            put "PM" into ampm
        END IF
        REPEAT for each char c in t
            IF c is a number THEN put c after t2
        END REPEAT

        SWITCH
        CASE the number of chars of t2 < 3
            put ":00" after t2
            break
        CASE the number of chars of t2 = 3
            put char 1 of t2 & ":" & char 2 to 3 of t2 into t2
            break
        CASE the number of chars of t2 = 4
            put char 1 to 2 of t2 & ":" & char 3 to 4 of t2 into t2
            break
        END SWITCH
        put space & ampm after t2
        put t2 into the target
    END convertTime
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to