home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
word2x0a.zip
/
source
/
usdate.cc
< prev
next >
Wrap
C/C++ Source or Header
|
1997-04-13
|
1KB
|
63 lines
/* $Id: usdate.cc,v 1.5 1997/04/13 15:46:48 dps Exp $ */
/* Date formatter for the UK */
#include "config.h"
#ifdef TM_IN_SYS_TIME
#include <sys/time.h>
#else
#include <time.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#else /* do not have sting.h */
#include <strings.h>
#endif /* HAVE_STRING_H */
#define __EXCLUDE_READER_CLASSES
#include "lib.h"
char *us_date(time_t when)
{
static const char *months[]=
{
"January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December",
};
struct tm *tim;
char date_buf[200];
const char *postfix;
tim=localtime(&when);
switch (tim->tm_mday % 10)
{
case 1:
postfix="st";
break;
case 2:
postfix="nd";
break;
case 3:
postfix="rd";
break;
default:
postfix="th";
break;
}
if (tim->tm_mday > 10 && tim->tm_mday < 14) postfix="th";
sprintf(date_buf, "%s %d%s, %d", months[tim->tm_mon],
tim->tm_mday, postfix, 1900+tim->tm_year);
return strdup(date_buf);
}