[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sh-utils: date.c time format is broken in non-English locale

From: Yukihiro Nakai
Subject: sh-utils: date.c time format is broken in non-English locale
Date: Fri, 13 Sep 2002 13:42:29 +0900

(Resent the patch attached because I've got no-mime advise...)

Hi GNU sh-utils maintainers,

I have wondered why the date format of date command in sh-utils is broken in
Japanese locale for a long time and got a chance to see and fix the code today.

1. HAVE_LANGINFO_H is not defined in config.h, so date.c skips to include

   DATE_FMT_LANGINFO() returns NULL, so Japanese locale date format will be
   automatically ignored. You should see HAVE_LANGINFO_CODESET as defined in 

2. You warn so that people don't wrap date format string to be gettextized with 
   but dcgettext() function will help this with LC_TIME specified. GNU 
   also uses this dcgettext().

Could you commit my change attached until next release of sh-utils?

Thank you.

Yukihiro Nakai, Red Hat Japan, Development

--- sh-utils-2.0.12/src/date.c.orig     2002-09-08 21:19:26.000000000 +0900
+++ sh-utils-2.0.12/src/date.c  2002-09-08 21:23:21.000000000 +0900
@@ -21,7 +21,7 @@
 #include <stdio.h>
 #include <getopt.h>
 #include <sys/types.h>
 # include <langinfo.h>
@@ -509,14 +509,7 @@
          char *date_fmt = DATE_FMT_LANGINFO ();
-         /* Do not wrap the following literal format string with _(...).
-            For example, suppose LC_ALL is unset, LC_TIME="POSIX",
-            and LANG="ko_KR".  In that case, POSIX says that LC_TIME
-            determines the format and contents of date and time strings
-            written by date, which means "date" must generate output
-            using the POSIX locale; but adding _() would cause "date"
-            to use a Korean translation of the format.  */
-         format = *date_fmt ? date_fmt : "%a %b %e %H:%M:%S %Z %Y";
+         format = *date_fmt ? date_fmt : dcgettext(NULL, N_("%a %b %e %H:%M:%S 
%Z %Y"), LC_TIME);
   else if (*format == '\0')
--- sh-utils-2.0.12/ChangeLog.orig      2002-09-08 21:23:54.000000000 +0900
+++ sh-utils-2.0.12/ChangeLog   2002-09-08 21:25:37.000000000 +0900
@@ -1,3 +1,8 @@
+2002-09-08  Yukihiro Nakai  <address@hidden>
+       * date.c: Use HAVE_LANGINFO_CODESET defined in config.h
+       * date.c: Use dcgettext to let LC_TIME value change date format
 2002-04-29  Jim Meyering  <address@hidden>
        * Version 2.0.12.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]