summaryrefslogtreecommitdiffstats
path: root/usr.bin/cal
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-01-24 22:50:24 +0000
committerache <ache@FreeBSD.org>1996-01-24 22:50:24 +0000
commit7c3532d5838fe35408132bf3021fd643c1dbd1bc (patch)
tree8782f51f7322b082292aa6af92008e16dbfbe264 /usr.bin/cal
parent0ed53cb0c5af956bc9d094beb3661f58aceb5e94 (diff)
downloadFreeBSD-src-7c3532d5838fe35408132bf3021fd643c1dbd1bc.zip
FreeBSD-src-7c3532d5838fe35408132bf3021fd643c1dbd1bc.tar.gz
Localize it.
Diffstat (limited to 'usr.bin/cal')
-rw-r--r--usr.bin/cal/cal.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/usr.bin/cal/cal.c b/usr.bin/cal/cal.c
index 9bf218d..3f20760 100644
--- a/usr.bin/cal/cal.c
+++ b/usr.bin/cal/cal.c
@@ -48,6 +48,7 @@ static char sccsid[] = "@(#)cal.c 8.4 (Berkeley) 4/2/94";
#include <ctype.h>
#include <err.h>
+#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -91,13 +92,10 @@ int sep1752[MAXDAYS] = {
SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE,
};
-char *month_names[12] = {
- "January", "February", "March", "April", "May", "June",
- "July", "August", "September", "October", "November", "December",
-};
+char *month_names[12];
-char *day_headings = "Su Mo Tu We Th Fr Sa";
-char *j_day_headings = " Su Mo Tu We Th Fr Sa";
+char day_headings[] = " ";
+char j_day_headings[] = " ";
/* leap year -- account for gregorian reformation in 1752 */
#define leap_year(yr) \
@@ -135,8 +133,12 @@ main(argc, argv)
char **argv;
{
struct tm *local_time;
+ static struct tm zero_tm;
time_t now;
- int ch, month, year, yflag;
+ int ch, month, year, yflag, i;
+ char buf[40];
+
+ (void) setlocale(LC_TIME, "");
yflag = 0;
while ((ch = getopt(argc, argv, "jy")) != EOF)
@@ -175,6 +177,18 @@ main(argc, argv)
usage();
}
+ for (i = 0; i < 12; i++) {
+ zero_tm.tm_mon = i;
+ strftime(buf, sizeof(buf), "%B", &zero_tm);
+ month_names[i] = strdup(buf);
+ }
+ for (i = 0; i < 7; i++) {
+ zero_tm.tm_wday = i;
+ strftime(buf, sizeof(buf), "%a", &zero_tm);
+ strncpy(day_headings + i * 3, buf, 2);
+ strncpy(j_day_headings + i * 4 + 1, buf, 2);
+ }
+
if (month)
monthly(month, year);
else if (julian)
OpenPOWER on IntegriCloud