0 7ˆl–ßi~”ên-jyAãb¸ÛjbÑ¿�þYrB¬Ón:HÞjWÝ ?ŸÂ „ @iÏÁÀ¿6Þ#!/usr/bin/mawk -We # edit the above to be the full pathname of 'mawk' # @(#) hcal - v01.00.02 - Tue Feb 27 21:21:21 EST 1996 # @(#) prints a 3-month (highlighted) calendar centered on the target month # @(#) may be edited for week to start with Sun or Mon & for local language # @(#) to display a usage screen, execute: hcal -h # NOTE: to edit, set ts=4 in 'vi' (or equivalent) # to print, pipe through 'pr -t -e4' # Using ideas from a KornShell script by Mikhail Kuperblum (mikhail@klm.com) # Bob Stockler - bob@trebor.iglou.com - Sysop CompuServe SCOForum [75162,1612] BEGIN { # Local Edits: PROG = "hcal" # Program name given to this script # FMT = 0 # date format dd/mm/yyyy # FMT1 = 0 # for weekdays ordered "Mo Tu We Th Fr Sa Su" FMT = 1 # date format mm/dd/yyyy FMT1 = 1 # for weekdays ordered "Su Mo Tu We Th Fr Sa" # edit day & month names and abbreviations for local language names Days[0] = "Mo Tu We Th Fr Sa Su" Days[1] = "Su Mo Tu We Th Fr Sa" MONTHS = "January February March April May June July August" MONTHS = MONTHS " September October November December" Months = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec" # STDOUT = 0 # emulate SCO Unix 'cal' (NO highlighting) STDOUT = 1 # default to highlight mode MINUS = "-" # possible input date field delimiter SLASH = "/" # possible input date field delimiter DOT = "." # possible input date field delimiter IDFD = "[" MINUS # make MINUS the first character in this series IDFD = IDFD SLASH # so that it stands for itself in the RE IDFD = IDFD DOT "]" # Input Date Field Delimiters RE ODFD = SLASH # Output Date Field Delimiter (default) DATE_FMT = "%.2d%s%.2d%s%.4d" # date format ## this script presumes 'date' recognizes these arguments in these ways: ## w - Day of the week - Sunday = 0 ## m - Month of year - 01 to 12 ## d - Day of month - 01 to 31 ## y Last 2 digits of year - 00 to 99 ## Y - Year (including century), as decimal numbers ## j - Day of the year - 001 to 366 (Julian date) ## T - Time as HH:MM:SS ## X Current time, as defined by the locale ## a - Abbreviated weekday - Sun to Sat ## b - Abbreviated month name ## Z - Timezone name, or no characters if no timezone exists ## Command to get today's date information: ## DATE = "/bin/date '+%w %m %d 19%y %j~%a %b %d %T %Z 19%y'" ## For sunos4 ## DATE = DATE = "/bin/date '+%w %m %d 19%y %j~%a %h %d %T 19%y'" DATE = "/bin/date '+%w %m %d %Y %j~%a %b %d %X %Z %Y'" # End of Local Edits INT_RE = "^[0-9]+$" # unsigned integer RE S_INT_RE = "^[-+][0-9]+$" # signed integer RE MNAM_RE = "^[A-Za-z]+$" # month name RE YEAR_RE = "^[0-9]?[0-9]?[0-9]?[0-9]$" DATE_RE = "^[0-9]?[0-9]" IDFD "[0-9]?[0-9]" IDFD "[0-9]?[0-9]?[0-9]?[0-9]$" DAT1_RE = "^[0-9]?[0-9]" IDFD "[0-9]?[0-9]$" split(Months,M_Name) split("31 28 31 30 31 30 31 31 30 31 30 31",Mdays) ; Mdays[0] = 0 NUM_ARGS = ARGC - 1 if ( ARGV[1] == "-x" ) { # standout mode switch if ( STDOUT == 1 ) STDOUT = 0 ; else STDOUT = 1 ARG1 = ARGV[2] ; ARG2 = ARGV[3] ; NUM_ARGS -= 1 } else if ( ARGV[1] ~ /^-[h?]$/ ) { HELP = 1 ; exit } else { ARG1 = ARGV[1] ; ARG2 = ARGV[2] } if ( STDOUT == 1 ) { # get the terminal standout-start & standout-end control codes so = ENVIRON["so"] ; if ( ! so ) "tput smso" | getline so se = ENVIRON["se"] ; if ( ! se ) "tput rmso" | getline se } if ( NUM_ARGS == 0 ) { # no arguments - print a calendar display centered on today DEFAULT = 1 } else if ( NUM_ARGS == 1 ) { # one argument - may be a month name, date, year, or interval of days if ( ARG1 ~ DATE_RE ) DATE1 = Fmt_Date(ARG1) else if ( ARG1 ~ DAT1_RE ) DATE1 = ARG1 else if ( ARG1 ~ MNAM_RE ) { Get_Mnum() ; DATE1 = RMSO = ARG1 "/1" } else if ( ARG1 ~ S_INT_RE ) INTERVAL = ARG1 + 0 else if ( ARG1 ~ INT_RE ) { if ( ARG1 > 0 && ARG1 <= 9999 ) YEAR = ARG1 + 0 else if ( ARG1 > 9999 ) { ERR = 9 ; exit } else { ERR = 7 ; exit } } else { ERR = 1 ; exit }