* NEWS: Reword the deprecation notice.
* modules/get_date: Rename to modules/parse-datetime.
* modules/get_date-tests: Rename to modules/parse-datetime-tests.
* m4/get_date.m4: Rename to m4/parse-datetime.m4.
* lib/get_date.y: Rename to lib/parse-datetime.y.
* tests/test-get_date.c: Rename to tests/test-parse-datetime.c.
* doc/get_date.texi: Rename to doc/parse-datetime.texi.
* doc/getdate.texi: Provide fallback wrapper.
* lib/getdate.h: Move guts, and wrap...
* lib/parse-datetime.h: ...new file.
* lib/parse-datetime.y (get_date): Rename...
(parse_datetime): ...to this.
* m4/parse-datetime.m4 (gl_GET_DATE): Rename...
(gl_PARSE_DATETIME): ...to this.
* doc/posix-functions/getdate.texi (get_date): Provide fallback
documentation.
* modules/getdate (Files): Provide fallback docs and header.
(Notice, Depends-on): Update references.
* tests/test-parse-datetime.c: Likewise.
* DEPENDENCIES: Likewise.
* MODULES.html.sh (Date and time <time.h>): Likewise.
* doc/parse-datetime.texi (Date input formats)
(Authors of parse_datetime): Likewise.
* modules/parse-datetime (Files, configure.ac, Makefile.am)
(Include): Likewise.
* modules/parse-datetime-tests (Files, Makefile.am): Likewise.
* gnulib-tool: Likewise.
* m4/bison.m4 (gl_BISON): Likewise.
Suggested by Bruno Haible.
Signed-off-by: Eric Blake <eblake@redhat.com>
2010-10-05 Eric Blake <eblake@redhat.com>
+ parse-datetime: better name than get_date
+ * NEWS: Reword the deprecation notice.
+ * modules/get_date: Rename to modules/parse-datetime.
+ * modules/get_date-tests: Rename to modules/parse-datetime-tests.
+ * m4/get_date.m4: Rename to m4/parse-datetime.m4.
+ * lib/get_date.y: Rename to lib/parse-datetime.y.
+ * tests/test-get_date.c: Rename to tests/test-parse-datetime.c.
+ * doc/get_date.texi: Rename to doc/parse-datetime.texi.
+ * doc/getdate.texi: Provide fallback wrapper.
+ * lib/getdate.h: Move guts, and wrap...
+ * lib/parse-datetime.h: ...new file.
+ * lib/parse-datetime.y (get_date): Rename...
+ (parse_datetime): ...to this.
+ * m4/parse-datetime.m4 (gl_GET_DATE): Rename...
+ (gl_PARSE_DATETIME): ...to this.
+ * doc/posix-functions/getdate.texi (get_date): Provide fallback
+ documentation.
+ * modules/getdate (Files): Provide fallback docs and header.
+ (Notice, Depends-on): Update references.
+ * tests/test-parse-datetime.c: Likewise.
+ * DEPENDENCIES: Likewise.
+ * MODULES.html.sh (Date and time <time.h>): Likewise.
+ * doc/parse-datetime.texi (Date input formats)
+ (Authors of parse_datetime): Likewise.
+ * modules/parse-datetime (Files, configure.ac, Makefile.am)
+ (Include): Likewise.
+ * modules/parse-datetime-tests (Files, Makefile.am): Likewise.
+ * gnulib-tool: Likewise.
+ * m4/bison.m4 (gl_BISON): Likewise.
+ Suggested by Bruno Haible.
+
bootstrap: fix Solaris regression
* build-aux/bootstrap (check_versions): Solaris tr still needs []
around ranges.
* Bison 2.0 or newer.
+ Recommended.
- Needed if you use the 'get_date' module.
+ Needed if you use the 'parse-datetime' module.
+ Homepage:
http://www.gnu.org/software/bison/
+ Download:
func_echo "$element"
func_begin_table
- func_module get_date
+ func_module parse-datetime
func_module timegm
func_module tzset
func_end_table
Date Modules Changes
-2010-09-30 getdate This module is deprecated. Please use get_date
- for get_date(), or help us write getdate-posix
- for getdate(). Also, doc/getdate.texi has been
- renamed to doc/get_date.texi.
+2010-10-05 getdate This module is deprecated. Please use the new
+ parse-datetime module for the replacement
+ function parse_datetime(), or help us write
+ getdate-posix for getdate(). Also, the header
+ "getdate.h" has been renamed "parse-datetime.h",
+ and doc/getdate.texi to doc/parse-datetime.texi.
2010-09-29 sys_wait This module no longer provides the waitpid()
function. If you need this function, you now need
--- /dev/null
+@include parse-datetime.texi
@chapter Date input formats
@cindex date input formats
-@findex get_date
+@findex parse_datetime
First, a quote:
This section describes the textual date representations that @sc{gnu}
programs accept. These are the strings you, as a user, can supply as
arguments to the various programs. The C interface (via the
-@code{get_date} function) is not described here.
+@code{parse_datetime} function) is not described here.
@menu
* General date syntax:: Common rules.
* Pure numbers in date strings:: 19931219, 1440.
* Seconds since the Epoch:: @@1078100502.
* Specifying time zone rules:: TZ="America/New_York", TZ="UTC0".
-* Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
+* Authors of parse_datetime:: Bellovin, Eggert, Salz, Berets, et al.
@end menu
regimes. @xref{TZ Variable,, Specifying the Time Zone with @code{TZ},
libc, The GNU C Library}.
-@node Authors of get_date
-@section Authors of @code{get_date}
+@node Authors of parse_datetime
+@section Authors of @code{parse_datetime}
+@c the anchor keeps the old node name, to try to avoid breaking links
+@anchor{Authors of get_date}
-@cindex authors of @code{get_date}
+@cindex authors of @code{parse_datetime}
@cindex Bellovin, Steven M.
@cindex Salz, Rich
Usenet, then completely overhauled by Rich $alz (@email{rsalz@@bbn.com})
and Jim Berets (@email{jberets@@bbn.com}) in August, 1990. Various
revisions for the @sc{gnu} system were made by David MacKenzie, Jim Meyering,
-Paul Eggert and others.
+Paul Eggert and others, including renaming it to @code{parse_datetime}
+to avoid confusion with the Posix function @code{getdate}.
@cindex Pinard, F.
@cindex Berry, K.
This chapter was originally produced by Fran@,{c}ois Pinard
-(@email{pinard@@iro.umontreal.ca}) from the @file{get_date.y} source code,
+(@email{pinard@@iro.umontreal.ca}) from the @file{parse_datetime.y} source code,
and then edited by K.@: Berry (@email{kb@@cs.umb.edu}).
MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, Cygwin, mingw, BeOS.
@end itemize
-Gnulib provides a module @code{get_date} that contains a function
-@code{get_date}
+Gnulib provides a module @code{parse-datetime} that contains a function
+@code{parse_datetime}
that has similar functionality as the @code{getdate} function.
) || func_exit 1
fi
# Need to run configure and make once, to create built files that are to be
- # distributed (such as get_date.c).
+ # distributed (such as parse-datetime.c).
sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
# Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
-/* Parse a string into an internal time stamp.
-
- Copyright (C) 1995, 1997, 1998, 2003, 2004, 2007, 2009, 2010 Free Software
- Foundation, Inc.
-
- 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
-
-#include <stdbool.h>
-#include <time.h>
-
-bool get_date (struct timespec *, char const *, struct timespec const *);
+/* Obsolete; consider using parse-datetime.h instead. */
+#include "parse-datetime.h"
+#define get_date(a, b, c) parse_datetime (a, b, c)
--- /dev/null
+/* Parse a string into an internal time stamp.
+
+ Copyright (C) 1995, 1997, 1998, 2003, 2004, 2007, 2009, 2010 Free Software
+ Foundation, Inc.
+
+ 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
+
+#include <stdbool.h>
+#include <time.h>
+
+bool parse_datetime (struct timespec *, char const *, struct timespec const *);
#include <config.h>
-#include "getdate.h"
+#include "parse-datetime.h"
#include "intprops.h"
#include "timespec.h"
P can be an incomplete or relative time specification; if so, use
*NOW as the basis for the returned time. */
bool
-get_date (struct timespec *result, char const *p, struct timespec const *now)
+parse_datetime (struct timespec *result, char const *p,
+ struct timespec const *now)
{
time_t Start;
long int Start_ns;
{
struct timespec d;
struct tm const *tm;
- if (! get_date (&d, buff, NULL))
+ if (! parse_datetime (&d, buff, NULL))
printf ("Bad format - couldn't convert.\n");
else if (! (tm = localtime (&d.tv_sec)))
{
AC_DEFUN([gl_BISON],
[
- # get_date.y works with bison only.
+ # parse-datetime.y works with bison only.
: ${YACC='bison -y'}
dnl
dnl Declaring YACC & YFLAGS precious will not be necessary after GNULIB
-# get_date.m4 serial 17
+# parse-datetime.m4 serial 18
dnl Copyright (C) 2002-2006, 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
fi
])
-AC_DEFUN([gl_GET_DATE],
+AC_DEFUN([gl_PARSE_DATETIME],
[
- dnl Prerequisites of lib/getdate.h.
+ dnl Prerequisites of lib/parse-datetime.h.
AC_REQUIRE([AM_STDBOOL_H])
AC_REQUIRE([gl_TIMESPEC])
- dnl Prerequisites of lib/get_date.y.
+ dnl Prerequisites of lib/parse-datetime.y.
AC_REQUIRE([gl_BISON])
AC_REQUIRE([gl_C_COMPOUND_LITERALS])
AC_STRUCT_TIMEZONE
+++ /dev/null
-Description:
-Convert a date/time string to linear time.
-
-Files:
-doc/get_date.texi
-lib/getdate.h
-lib/get_date.y
-m4/bison.m4
-m4/tm_gmtoff.m4
-m4/get_date.m4
-
-Depends-on:
-c-ctype
-stdbool
-gettime
-intprops
-mktime
-setenv
-unsetenv
-time
-verify
-xalloc
-
-configure.ac:
-gl_GET_DATE
-
-Makefile.am:
-# This rule overrides the Automake generated .y.c rule, to ensure that the
-# get_date.c file gets generated in the source directory, not in the build
-# directory.
-get_date.c: get_date.y
- $(AM_V_GEN)$(SHELL) $(YLWRAP) $(srcdir)/get_date.y \
- y.tab.c get_date.c \
- y.tab.h getdate.h \
- y.output get_date.output \
- -- $(YACC) $(YFLAGS) $(AM_YFLAGS) && \
- mv get_date.c get_date.c-t && \
- mv get_date.c-t $(srcdir)/get_date.c
-lib_SOURCES += get_date.y
-BUILT_SOURCES += get_date.c
-MOSTLYCLEANFILES += get_date.c-t
-MAINTAINERCLEANFILES += get_date.c
-EXTRA_DIST += get_date.c
-
-Include:
-"getdate.h"
-
-License:
-GPL
-
-Maintainer:
-Paul Eggert
+++ /dev/null
-Files:
-tests/test-get_date.c
-tests/macros.h
-
-Depends-on:
-progname
-setenv
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-get_date
-check_PROGRAMS += test-get_date
-test_get_date_LDADD = $(LDADD) @LIBINTL@ $(LIB_CLOCK_GETTIME)
obsolete
Notice:
-This module is obsolete. Use the module 'get_date' instead.
+This module is obsolete. Use the module 'parse-datetime' instead.
Files:
+doc/getdate.texi
+lib/getdate.h
Depends-on:
-get_date
+parse-datetime
configure.ac:
--- /dev/null
+Description:
+Convert a date/time string to linear time.
+
+Files:
+doc/parse-datetime.texi
+lib/parse-datetime.h
+lib/parse-datetime.y
+m4/bison.m4
+m4/tm_gmtoff.m4
+m4/parse-datetime.m4
+
+Depends-on:
+c-ctype
+stdbool
+gettime
+intprops
+mktime
+setenv
+unsetenv
+time
+verify
+xalloc
+
+configure.ac:
+gl_PARSE_DATETIME
+
+Makefile.am:
+# This rule overrides the Automake generated .y.c rule, to ensure that the
+# parse-datetime.c file gets generated in the source directory, not in the
+# build directory.
+parse-datetime.c: parse-datetime.y
+ $(AM_V_GEN)$(SHELL) $(YLWRAP) $(srcdir)/parse-datetime.y \
+ y.tab.c parse-datetime.c \
+ y.tab.h parse-datetime.h \
+ y.output parse-datetime.output \
+ -- $(YACC) $(YFLAGS) $(AM_YFLAGS) && \
+ mv parse-datetime.c parse-datetime.c-t && \
+ mv parse-datetime.c-t $(srcdir)/parse-datetime.c
+lib_SOURCES += parse-datetime.y
+BUILT_SOURCES += parse-datetime.c
+MOSTLYCLEANFILES += parse-datetime.c-t
+MAINTAINERCLEANFILES += parse-datetime.c
+EXTRA_DIST += parse-datetime.c
+
+Include:
+"parse-datetime.h"
+
+License:
+GPL
+
+Maintainer:
+Paul Eggert
--- /dev/null
+Files:
+tests/test-parse-datetime.c
+tests/macros.h
+
+Depends-on:
+progname
+setenv
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-parse-datetime
+check_PROGRAMS += test-parse-datetime
+test_parse_datetime_LDADD = $(LDADD) @LIBINTL@ $(LIB_CLOCK_GETTIME)
-/* Test of getdate() function.
+/* Test of parse_datetime() function.
Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
#include <config.h>
-#include "getdate.h"
+#include "parse-datetime.h"
#include <stdio.h>
#include <stdlib.h>
now.tv_sec = 4711;
now.tv_nsec = 1267;
p = "now";
- ASSERT (get_date (&result, p, &now));
+ ASSERT (parse_datetime (&result, p, &now));
LOG (p, now, result);
ASSERT (now.tv_sec == result.tv_sec && now.tv_nsec == result.tv_nsec);
now.tv_sec = 4711;
now.tv_nsec = 1267;
p = "tomorrow";
- ASSERT (get_date (&result, p, &now));
+ ASSERT (parse_datetime (&result, p, &now));
LOG (p, now, result);
ASSERT (now.tv_sec + 24 * 60 * 60 == result.tv_sec
&& now.tv_nsec == result.tv_nsec);
now.tv_sec = 4711;
now.tv_nsec = 1267;
p = "yesterday";
- ASSERT (get_date (&result, p, &now));
+ ASSERT (parse_datetime (&result, p, &now));
LOG (p, now, result);
ASSERT (now.tv_sec - 24 * 60 * 60 == result.tv_sec
&& now.tv_nsec == result.tv_nsec);
now.tv_sec = 4711;
now.tv_nsec = 1267;
p = "4 hours";
- ASSERT (get_date (&result, p, &now));
+ ASSERT (parse_datetime (&result, p, &now));
LOG (p, now, result);
ASSERT (now.tv_sec + 4 * 60 * 60 == result.tv_sec
&& now.tv_nsec == result.tv_nsec);
now.tv_sec = 4711;
now.tv_nsec = 1267;
p = "UTC+400 +24 hours";
- ASSERT (get_date (&result, p, &now));
+ ASSERT (parse_datetime (&result, p, &now));
LOG (p, now, result);
p = "UTC+400 +1 day";
- ASSERT (get_date (&result2, p, &now));
+ ASSERT (parse_datetime (&result2, p, &now));
LOG (p, now, result2);
ASSERT (result.tv_sec == result2.tv_sec
&& result.tv_nsec == result2.tv_nsec);
now.tv_sec = 4711;
now.tv_nsec = 1267;
p = "UTC+14:00";
- ASSERT (get_date (&result, p, &now));
+ ASSERT (parse_datetime (&result, p, &now));
LOG (p, now, result);
p = "UTC+14";
- ASSERT (get_date (&result2, p, &now));
+ ASSERT (parse_datetime (&result2, p, &now));
LOG (p, now, result2);
ASSERT (result.tv_sec == result2.tv_sec
&& result.tv_nsec == result2.tv_nsec);
p = "UTC+1400";
- ASSERT (get_date (&result2, p, &now));
+ ASSERT (parse_datetime (&result2, p, &now));
LOG (p, now, result2);
ASSERT (result.tv_sec == result2.tv_sec
&& result.tv_nsec == result2.tv_nsec);
now.tv_sec = 4711;
now.tv_nsec = 1267;
p = "UTC-14:00";
- ASSERT (get_date (&result, p, &now));
+ ASSERT (parse_datetime (&result, p, &now));
LOG (p, now, result);
p = "UTC-14";
- ASSERT (get_date (&result2, p, &now));
+ ASSERT (parse_datetime (&result2, p, &now));
LOG (p, now, result2);
ASSERT (result.tv_sec == result2.tv_sec
&& result.tv_nsec == result2.tv_nsec);
p = "UTC-1400";
- ASSERT (get_date (&result2, p, &now));
+ ASSERT (parse_datetime (&result2, p, &now));
LOG (p, now, result2);
ASSERT (result.tv_sec == result2.tv_sec
&& result.tv_nsec == result2.tv_nsec);
now.tv_sec = 4711;
now.tv_nsec = 1267;
p = "UTC+0:15";
- ASSERT (get_date (&result, p, &now));
+ ASSERT (parse_datetime (&result, p, &now));
LOG (p, now, result);
p = "UTC+0015";
- ASSERT (get_date (&result2, p, &now));
+ ASSERT (parse_datetime (&result2, p, &now));
LOG (p, now, result2);
ASSERT (result.tv_sec == result2.tv_sec
&& result.tv_nsec == result2.tv_nsec);
now.tv_sec = 4711;
now.tv_nsec = 1267;
p = "UTC-1:30";
- ASSERT (get_date (&result, p, &now));
+ ASSERT (parse_datetime (&result, p, &now));
LOG (p, now, result);
p = "UTC-130";
- ASSERT (get_date (&result2, p, &now));
+ ASSERT (parse_datetime (&result2, p, &now));
LOG (p, now, result2);
ASSERT (result.tv_sec == result2.tv_sec
&& result.tv_nsec == result2.tv_nsec);
- /* TZ out of range should cause get_date failure */
+ /* TZ out of range should cause parse_datetime failure */
now.tv_sec = 4711;
now.tv_nsec = 1267;
p = "UTC+25:00";
- ASSERT (!get_date (&result, p, &now));
+ ASSERT (!parse_datetime (&result, p, &now));
/* Check for several invalid countable dayshifts */
now.tv_sec = 4711;
now.tv_nsec = 1267;
p = "UTC+4:00 +40 yesterday";
- ASSERT (!get_date (&result, p, &now));
+ ASSERT (!parse_datetime (&result, p, &now));
p = "UTC+4:00 next yesterday";
- ASSERT (!get_date (&result, p, &now));
+ ASSERT (!parse_datetime (&result, p, &now));
p = "UTC+4:00 tomorrow ago";
- ASSERT (!get_date (&result, p, &now));
+ ASSERT (!parse_datetime (&result, p, &now));
p = "UTC+4:00 40 now ago";
- ASSERT (!get_date (&result, p, &now));
+ ASSERT (!parse_datetime (&result, p, &now));
p = "UTC+4:00 last tomorrow";
- ASSERT (!get_date (&result, p, &now));
+ ASSERT (!parse_datetime (&result, p, &now));
p = "UTC+4:00 -4 today";
- ASSERT (!get_date (&result, p, &now));
+ ASSERT (!parse_datetime (&result, p, &now));
/* And check correct usage of dayshifts */
now.tv_sec = 4711;
now.tv_nsec = 1267;
p = "UTC+400 tomorrow";
- ASSERT (get_date (&result, p, &now));
+ ASSERT (parse_datetime (&result, p, &now));
LOG (p, now, result);
p = "UTC+400 +1 day";
- ASSERT (get_date (&result2, p, &now));
+ ASSERT (parse_datetime (&result2, p, &now));
LOG (p, now, result2);
ASSERT (result.tv_sec == result2.tv_sec
&& result.tv_nsec == result2.tv_nsec);
now.tv_sec = 4711;
now.tv_nsec = 1267;
p = "UTC+400 yesterday";
- ASSERT (get_date (&result, p, &now));
+ ASSERT (parse_datetime (&result, p, &now));
LOG (p, now, result);
p = "UTC+400 1 day ago";
- ASSERT (get_date (&result2, p, &now));
+ ASSERT (parse_datetime (&result2, p, &now));
LOG (p, now, result2);
ASSERT (result.tv_sec == result2.tv_sec
&& result.tv_nsec == result2.tv_nsec);
now.tv_sec = 4711;
now.tv_nsec = 1267;
p = "UTC+400 now";
- ASSERT (get_date (&result, p, &now));
+ ASSERT (parse_datetime (&result, p, &now));
LOG (p, now, result);
p = "UTC+400 +0 minutes"; /* silly, but simple "UTC+400" is different*/
- ASSERT (get_date (&result2, p, &now));
+ ASSERT (parse_datetime (&result2, p, &now));
LOG (p, now, result2);
ASSERT (result.tv_sec == result2.tv_sec
&& result.tv_nsec == result2.tv_nsec);
sprintf (tmp, "NEXT %s", day_table[i]);
now.tv_sec = thur2 + 4711;
now.tv_nsec = 1267;
- ASSERT (get_date (&result, tmp, &now));
+ ASSERT (parse_datetime (&result, tmp, &now));
LOG (tmp, now, result);
ASSERT (result.tv_nsec == 0);
ASSERT (result.tv_sec == thur2 + (i == 4 ? 7 : (i + 3) % 7) * 24 * 3600);
sprintf (tmp, "LAST %s", day_table[i]);
now.tv_sec = thur2 + 4711;
now.tv_nsec = 1267;
- ASSERT (get_date (&result, tmp, &now));
+ ASSERT (parse_datetime (&result, tmp, &now));
LOG (tmp, now, result);
ASSERT (result.tv_nsec == 0);
ASSERT (result.tv_sec == thur2 + ((i + 3) % 7 - 7) * 24 * 3600);
p = "THURSDAY UTC+00"; /* The epoch was on Thursday. */
now.tv_sec = 0;
now.tv_nsec = 0;
- ASSERT (get_date (&result, p, &now));
+ ASSERT (parse_datetime (&result, p, &now));
LOG (p, now, result);
ASSERT (result.tv_sec == now.tv_sec
&& result.tv_nsec == now.tv_nsec);
p = "FRIDAY UTC+00";
now.tv_sec = 0;
now.tv_nsec = 0;
- ASSERT (get_date (&result, p, &now));
+ ASSERT (parse_datetime (&result, p, &now));
LOG (p, now, result);
ASSERT (result.tv_sec == 24 * 3600
&& result.tv_nsec == now.tv_nsec);