parm d="" # ************************************************************* # * # * This command file converts an integer packed date into a # * displayable date format in the form MM/DD/YYYY. The # * input may be entered as a PARM with the command filename # * or when prompted. # * # * The packed date may be of the data type 2I1 or I2. The # * 2I1 data type is stored as a compound data element. The # * first element is the year stored as a half-word data # * element. The year requires no conversion to be display- # * able. The second data element is the month and day # * stored as 2 bytes (half-word). The month is the left byte # * and the day is the right byte. Conversion is # * necessary for the month and day to be displayed in a # * recognizable form. When using this command utility to convert # * 2I1 packed dates, provide only the Month and Day portion # * of the packed date value. # * # * the I2 data type is a single integer data element con- # * taining the year in the left half-word and the month # * and the day in the right half-word. The entire data # * element must be converted in order to be displayed in a # * recognizable form. # * # * This command file will distinguish between the two differ- # * ent data types based on the size of the input and convert # * them appropriately. # * # * Note: The only edit checking performed by this # * command file is to verify that the input is numeric. # * The validity and reasonableness of the output is # * is determined by the validity and accuracy of the # * input. # * # * Written by: Steven P. Barrett # * Date: 04/23/1993 # ************************************************************* setvar year 0 setvar val "!d" # ************************************************************* # * If no PARM value, prompt for it. # ************************************************************* if "!val" = "" input val;prompt="ENTER A PACKED INTEGER DATE >" endif # ************************************************************* # * If the input is NULL, return back to the caller. # ************************************************************* if "!val" = "" return endif # ************************************************************* # * If not numeric, display error and return to caller. # ************************************************************* if numeric("!val") = FALSE echo echo ERROR - The input must be numeric. echo deletevar val,d return endif # ************************************************************* # * Convert the input to HEX and seperate the elements. # ************************************************************* setvar real hex(!val) if (len("![real]") - 1) > 4 setvar year "![real]" setvar real "$"+(rht("![real]",4)) setvar year str("![year]",1,(len("![year]")-4)) setvar year !year endif setvar real str("![real]",2,((len("![real]"))-1)) setvar unpmo str("![real]",1,((len("![real]"))-2)) setvar unpday rht("![real]",2) setvar unpmo "$"+"![unpmo]" setvar unpday "$"+"![unpday]" if "![unpmo]" = "$" setvar unpmo "$0" endif # ************************************************************* # * Convert back to DECIMAL, construct a display- # * able date format and display it. # ************************************************************* setvar unpmo !unpmo setvar unpday !unpday setvar modayyr "!unpmo"+"/"+"!unpday"+"/"+"!year" echo echo The unpacked month, day and year is !modayyr echo # ************************************************************* # * Clean up the environment. The date string is # * retained in a variable named MODAYYR. # ************************************************************* deletevar val,real,unpmo,unpday,year