[417] in Zephyr_Comments

home help back first fref pref prev next nref lref last post

[The Danceaholic: Revised code fragment for .zwgc.desc]

daemon@ATHENA.MIT.EDU (John T Kohl)
Thu Jan 11 08:40:38 1990

Date: Thu, 11 Jan 90 08:40:24 -0500
From: John T Kohl <jtkohl@ATHENA.MIT.EDU>
To: zephyr-comments@ATHENA.MIT.EDU


------- Forwarded Message

From: wizard@ATHENA.MIT.EDU
To: jtkohl@ATHENA.MIT.EDU
Subject: Revised code fragment for .zwgc.desc
Date: Wed, 10 Jan 90 22:16:20 EST

Hi!

The last code fragment I E-mailed to you had a bug in it.  If the $hour
variable had a value of "10", the $time variable had no hour on it.  This
revision should correct it.

This code is meant to change the format of the time to civilian format.
-------------------------------
# look in the direct /mit/zephyr/examples for more example fragments
# like this
#
# This file describes how to convert the standard 24-hour military time to
# the 12-hour civilian time (e.g. 21:00:00 --> 9:00:00 PM)
#
# This fragment goes immediately before the 'case $class / match "MESSAGE"'
# commands near the beginning of the standard .zwgc.desc file

set hr = lany($time, "00")

# This command takes the "raw" hour (on the 24-hour scale) and leaves the
# variable $time with the minutes and seconds.

case $hr
match "00"
        set hour = "12"
        set part = "AM"
match "12"
        set part = "PM"
match "13"
        set hour = "1"
        set part = "PM"
match "14"
        set hour = "2"
        set part = "PM"
match "15"
        set hour = "3"
        set part = "PM"
match "16"
        set hour = "4"
        set part = "PM"
match "17"
        set hour = "5"
        set part = "PM"
match "18"
        set hour = "6"
        set part = "PM"
match "19"
        set hour = "7"
        set part = "PM"
match "20"
        set hour = "8"
        set part = "PM"
match "21"
        set hour = "9"
        set part = "PM"
match "22"
        set hour = "10"
        set part = "PM"
match "23"
        set hour = "11"
        set part = "PM"
default
        set part = "AM"
endcase

# This case statement changes the 24-hour scale to the appropriate 12-hour
# scale, and also returns "AM" or "PM" as appropriate.

set time = rbreak("0", $hour)+$time+" "+$part

# This runs it all together.  The rbreak function is used to strip off any
# trailing "0" at the front of the $hour variable.

if ($time =~ ":*") then
	set time = "10"+$time
endif

# This is a fix to remedy the program's stripping the "10" off $time at the
# rbreak command.   [Note:   rbreak("0", "10") = ""]

------- End Forwarded Message

home help back first fref pref prev next nref lref last post