msginit.
+2001-10-08 Bruno Haible <haible@clisp.cons.org>
+
+ * po-time.h: New file.
+ * po-time.c: New file, extracted from xgettext.c.
+ * xgettext.c: Include po-time.h.
+ (difftm): Move to po-time.c.
+ (construct_header): Move some code to po-time.c. Call po_strftime.
+ * Makefile.am (noinst_HEADERS): Add po-time.h.
+ (xgettext_SOURCES): Add po-time.c.
+
2001-09-29 Bruno Haible <haible@clisp.cons.org>
* user-email.in: New file.
noinst_HEADERS = pos.h message.h po-gram.h po-hash.h po-charset.h po-lex.h \
po.h open-po.h read-po.h str-list.h write-po.h dir-list.h file-list.h \
po-gram-gen.h po-hash-gen.h msgl-charset.h msgl-equal.h msgl-iconv.h \
-msgl-ascii.h msgl-cat.h msgfmt.h read-mo.h write-mo.h xgettext.h x-c.h x-po.h \
-x-java.h x-ycp.h x-rst.h
+msgl-ascii.h msgl-cat.h msgfmt.h read-mo.h write-mo.h po-time.h xgettext.h \
+x-c.h x-po.h x-java.h x-ycp.h x-rst.h
EXTRA_DIST = FILES
msgfmt_SOURCES = msgfmt.c $(COMMON_SOURCE) msgl-ascii.c msgl-iconv.c write-mo.c write-java.c plural.c plural-eval.c $(FORMAT_SOURCE)
msgmerge_SOURCES = msgmerge.c $(COMMON_SOURCE) msgl-ascii.c write-po.c read-po.c msgl-equal.c
msgunfmt_SOURCES = msgunfmt.c $(COMMON_SOURCE) msgl-ascii.c write-po.c read-po.c read-mo.c read-java.c
-xgettext_SOURCES = xgettext.c $(COMMON_SOURCE) msgl-ascii.c write-po.c file-list.c x-c.c x-po.c x-java.l x-ycp.c x-rst.c $(FORMAT_SOURCE)
+xgettext_SOURCES = xgettext.c $(COMMON_SOURCE) msgl-ascii.c write-po.c file-list.c po-time.c x-c.c x-po.c x-java.l x-ycp.c x-rst.c $(FORMAT_SOURCE)
msgattrib_SOURCES = msgattrib.c $(COMMON_SOURCE) msgl-ascii.c write-po.c read-po.c
msgcat_SOURCES = msgcat.c $(COMMON_SOURCE) msgl-ascii.c write-po.c read-po.c msgl-iconv.c msgl-cat.c file-list.c
msgcomm_SOURCES = msgcomm.c $(COMMON_SOURCE) msgl-ascii.c write-po.c read-po.c msgl-iconv.c msgl-cat.c file-list.c
--- /dev/null
+/* PO/POT file timestamps.
+ Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
+ Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, April 1995.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include "po-time.h"
+
+#include "xerror.h"
+
+
+/* Prototypes for local functions. Needed to ensure compiler checking of
+ function argument counts despite of K&R C function definition syntax. */
+static long difftm PARAMS ((const struct tm *a, const struct tm *b));
+
+
+#define TM_YEAR_ORIGIN 1900
+
+/* Yield A - B, measured in seconds. */
+static long
+difftm (a, b)
+ const struct tm *a;
+ const struct tm *b;
+{
+ int ay = a->tm_year + TM_YEAR_ORIGIN - 1;
+ int by = b->tm_year + TM_YEAR_ORIGIN - 1;
+ /* Some compilers cannot handle this as a single return statement. */
+ long days = (
+ /* difference in day of year */
+ a->tm_yday - b->tm_yday
+ /* + intervening leap days */
+ + ((ay >> 2) - (by >> 2))
+ - (ay / 100 - by / 100)
+ + ((ay / 100 >> 2) - (by / 100 >> 2))
+ /* + difference in years * 365 */
+ + (long) (ay - by) * 365l);
+
+ return 60l * (60l * (24l * days + (a->tm_hour - b->tm_hour))
+ + (a->tm_min - b->tm_min))
+ + (a->tm_sec - b->tm_sec);
+}
+
+
+char *
+po_strftime (tp)
+ const time_t *tp;
+{
+ struct tm local_time;
+ char tz_sign;
+ long tz_min;
+
+ local_time = *localtime (tp);
+ tz_sign = '+';
+ tz_min = difftm (&local_time, gmtime (tp)) / 60;
+ if (tz_min < 0)
+ {
+ tz_min = -tz_min;
+ tz_sign = '-';
+ }
+ return xasprintf ("%d-%02d-%02d %02d:%02d%c%02ld%02ld",
+ local_time.tm_year + TM_YEAR_ORIGIN,
+ local_time.tm_mon + 1,
+ local_time.tm_mday,
+ local_time.tm_hour,
+ local_time.tm_min,
+ tz_sign, tz_min / 60, tz_min % 60);
+}
--- /dev/null
+/* PO/POT file timestamps.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ Written by Bruno Haible <haible@clisp.cons.org>, 2001.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _PO_TIME_H
+#define _PO_TIME_H
+
+#include <time.h>
+
+/* Return a freshly allocated string containing the given time in the
+ format YYYY-MM-DD HH:MM+TZOFF. */
+extern char *po_strftime PARAMS ((const time_t *tp));
+
+#endif /* _PO_TIME_H */
#include "system.h"
#include "po.h"
#include "message.h"
+#include "po-time.h"
#include "write-po.h"
#include "format.h"
#include "libgettext.h"
static void extract_from_file PARAMS ((const char *file_name,
extractor_func extractor,
msgdomain_list_ty *mdlp));
-static long difftm PARAMS ((const struct tm *a, const struct tm *b));
static message_ty *construct_header PARAMS ((void));
static extractor_func language_to_extractor PARAMS ((const char *name));
static const char *extension_to_language PARAMS ((const char *extension));
}
-#define TM_YEAR_ORIGIN 1900
-
-/* Yield A - B, measured in seconds. */
-static long
-difftm (a, b)
- const struct tm *a;
- const struct tm *b;
-{
- int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
- int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
- /* Some compilers cannot handle this as a single return statement. */
- long days = (
- /* difference in day of year */
- a->tm_yday - b->tm_yday
- /* + intervening leap days */
- + ((ay >> 2) - (by >> 2))
- - (ay / 100 - by / 100)
- + ((ay / 100 >> 2) - (by / 100 >> 2))
- /* + difference in years * 365 */
- + (long) (ay - by) * 365l);
-
- return 60l * (60l * (24l * days + (a->tm_hour - b->tm_hour))
- + (a->tm_min - b->tm_min))
- + (a->tm_sec - b->tm_sec);
-}
-
-
static message_ty *
construct_header ()
{
time_t now;
- struct tm local_time;
+ char *timestring;
message_ty *mp;
char *msgstr;
static lex_pos_ty pos = { __FILE__, __LINE__, };
- char tz_sign;
- long tz_min;
time (&now);
- local_time = *localtime (&now);
- tz_sign = '+';
- tz_min = difftm (&local_time, gmtime (&now)) / 60;
- if (tz_min < 0)
- {
- tz_min = -tz_min;
- tz_sign = '-';
- }
+ timestring = po_strftime (&now);
msgstr = xasprintf ("\
Project-Id-Version: PACKAGE VERSION\n\
-POT-Creation-Date: %d-%02d-%02d %02d:%02d%c%02ld%02ld\n\
+POT-Creation-Date: %s\n\
PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n\
Last-Translator: FULL NAME <EMAIL@ADDRESS>\n\
Language-Team: LANGUAGE <LL@li.org>\n\
MIME-Version: 1.0\n\
Content-Type: text/plain; charset=CHARSET\n\
Content-Transfer-Encoding: 8bit\n",
- local_time.tm_year + TM_YEAR_ORIGIN,
- local_time.tm_mon + 1,
- local_time.tm_mday,
- local_time.tm_hour,
- local_time.tm_min,
- tz_sign, tz_min / 60, tz_min % 60);
+ timestring);
+ free (timestring);
mp = message_alloc ("", NULL, msgstr, strlen (msgstr) + 1, &pos);