Re: printing month names in reports
Posted in 1993
root@candle.uucp (Bruce Momjian) writes: >Is there a way to print a date variable as > January 4, 1993 I wrote this C function a few years ago. --Glen ------------------------------------------------------------------------ #include <stdio.h> #include <ctype.h> /* Name: nice_date Description: Takes a 4gl date and returns a string with the date formatted as in January 1, 1988 Calling Sequence: let string_date = nice_date(fgl_date) Returns: A string which is at most 18 characters long, not including the null terminator */ nice_date(param_count) int param_count; { short int the_month, the_day, the_year; char buffer[20]; long in_date; static char *months[13] = { "", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; if (param_count != 1) { fprintf(stderr, "nice_date: called with %d parameters not 1\\n", param_count); exit(1); } popdate(&in_date); pushdate(in_date); _domonth(); popshort(&the_month); pushdate(in_date); _doday(); popshort(&the_day); pushdate(in_date); _doyear(); popshort(&the_year); sprintf(buffer, "%s %d, %d", months[the_month], the_day, the_year); retquote(buffer); return (1); } -- Glen Gordon | Internet: ggordon@agsm.ucla.edu Computing Services | Bitnet : ggordon@uclagsm.bitnet Anderson Graduate School of Management | AT&Tnet : (310) 206-6590 University of California, Los Angeles | Fax : (310) 206-2002