summaryrefslogtreecommitdiff
path: root/support/word2x/ukdate.cc
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/word2x/ukdate.cc
Initial commit
Diffstat (limited to 'support/word2x/ukdate.cc')
-rw-r--r--support/word2x/ukdate.cc61
1 files changed, 61 insertions, 0 deletions
diff --git a/support/word2x/ukdate.cc b/support/word2x/ukdate.cc
new file mode 100644
index 0000000000..5f7a09bf2e
--- /dev/null
+++ b/support/word2x/ukdate.cc
@@ -0,0 +1,61 @@
+/* $Id: ukdate.cc,v 1.4 1997/04/13 15:42:32 dps Exp $ */
+/* Date formatter for the UK */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+#ifdef TM_IN_SYS_TIME
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif /* HAVE_STRING_H */
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif /* HAVE_STRINGS_H */
+#define __EXCLUDE_READER_CLASSES
+#include "lib.h"
+
+char *uk_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, "%d%s %s, %d", tim->tm_mday, postfix,
+ months[tim->tm_mon], 1900+tim->tm_year);
+
+ return strdup(date_buf);
+}
+
+
+