mirror of
https://git.savannah.gnu.org/git/gnulib.git
synced 2025-08-08 17:22:05 +03:00
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. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
31
ChangeLog
31
ChangeLog
@@ -8,6 +8,37 @@
|
|||||||
|
|
||||||
2010-10-05 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
|
bootstrap: fix Solaris regression
|
||||||
* build-aux/bootstrap (check_versions): Solaris tr still needs []
|
* build-aux/bootstrap (check_versions): Solaris tr still needs []
|
||||||
around ranges.
|
around ranges.
|
||||||
|
@@ -101,7 +101,7 @@ at any time.
|
|||||||
|
|
||||||
* Bison 2.0 or newer.
|
* Bison 2.0 or newer.
|
||||||
+ Recommended.
|
+ Recommended.
|
||||||
Needed if you use the 'get_date' module.
|
Needed if you use the 'parse-datetime' module.
|
||||||
+ Homepage:
|
+ Homepage:
|
||||||
http://www.gnu.org/software/bison/
|
http://www.gnu.org/software/bison/
|
||||||
+ Download:
|
+ Download:
|
||||||
|
@@ -1835,7 +1835,7 @@ func_all_modules ()
|
|||||||
func_echo "$element"
|
func_echo "$element"
|
||||||
|
|
||||||
func_begin_table
|
func_begin_table
|
||||||
func_module get_date
|
func_module parse-datetime
|
||||||
func_module timegm
|
func_module timegm
|
||||||
func_module tzset
|
func_module tzset
|
||||||
func_end_table
|
func_end_table
|
||||||
|
10
NEWS
10
NEWS
@@ -12,10 +12,12 @@ User visible incompatible changes
|
|||||||
|
|
||||||
Date Modules Changes
|
Date Modules Changes
|
||||||
|
|
||||||
2010-09-30 getdate This module is deprecated. Please use get_date
|
2010-10-05 getdate This module is deprecated. Please use the new
|
||||||
for get_date(), or help us write getdate-posix
|
parse-datetime module for the replacement
|
||||||
for getdate(). Also, doc/getdate.texi has been
|
function parse_datetime(), or help us write
|
||||||
renamed to doc/get_date.texi.
|
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()
|
2010-09-29 sys_wait This module no longer provides the waitpid()
|
||||||
function. If you need this function, you now need
|
function. If you need this function, you now need
|
||||||
|
1
doc/getdate.texi
Normal file
1
doc/getdate.texi
Normal file
@@ -0,0 +1 @@
|
|||||||
|
@include parse-datetime.texi
|
@@ -14,7 +14,7 @@
|
|||||||
@chapter Date input formats
|
@chapter Date input formats
|
||||||
|
|
||||||
@cindex date input formats
|
@cindex date input formats
|
||||||
@findex get_date
|
@findex parse_datetime
|
||||||
|
|
||||||
First, a quote:
|
First, a quote:
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ or a week from Sunday, with feelings of helpless confusion. @dots{}
|
|||||||
This section describes the textual date representations that @sc{gnu}
|
This section describes the textual date representations that @sc{gnu}
|
||||||
programs accept. These are the strings you, as a user, can supply as
|
programs accept. These are the strings you, as a user, can supply as
|
||||||
arguments to the various programs. The C interface (via the
|
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
|
@menu
|
||||||
* General date syntax:: Common rules.
|
* General date syntax:: Common rules.
|
||||||
@@ -57,7 +57,7 @@ arguments to the various programs. The C interface (via the
|
|||||||
* Pure numbers in date strings:: 19931219, 1440.
|
* Pure numbers in date strings:: 19931219, 1440.
|
||||||
* Seconds since the Epoch:: @@1078100502.
|
* Seconds since the Epoch:: @@1078100502.
|
||||||
* Specifying time zone rules:: TZ="America/New_York", TZ="UTC0".
|
* 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
|
@end menu
|
||||||
|
|
||||||
|
|
||||||
@@ -530,10 +530,12 @@ daylight saving time; other rules can specify simple daylight saving
|
|||||||
regimes. @xref{TZ Variable,, Specifying the Time Zone with @code{TZ},
|
regimes. @xref{TZ Variable,, Specifying the Time Zone with @code{TZ},
|
||||||
libc, The GNU C Library}.
|
libc, The GNU C Library}.
|
||||||
|
|
||||||
@node Authors of get_date
|
@node Authors of parse_datetime
|
||||||
@section Authors of @code{get_date}
|
@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 Bellovin, Steven M.
|
||||||
@cindex Salz, Rich
|
@cindex Salz, Rich
|
||||||
@@ -547,10 +549,11 @@ at Chapel Hill. The code was later tweaked by a couple of people on
|
|||||||
Usenet, then completely overhauled by Rich $alz (@email{rsalz@@bbn.com})
|
Usenet, then completely overhauled by Rich $alz (@email{rsalz@@bbn.com})
|
||||||
and Jim Berets (@email{jberets@@bbn.com}) in August, 1990. Various
|
and Jim Berets (@email{jberets@@bbn.com}) in August, 1990. Various
|
||||||
revisions for the @sc{gnu} system were made by David MacKenzie, Jim Meyering,
|
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 Pinard, F.
|
||||||
@cindex Berry, K.
|
@cindex Berry, K.
|
||||||
This chapter was originally produced by Fran@,{c}ois Pinard
|
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}).
|
and then edited by K.@: Berry (@email{kb@@cs.umb.edu}).
|
@@ -17,6 +17,6 @@ This function is missing on some platforms:
|
|||||||
MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, Cygwin, mingw, BeOS.
|
MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, Cygwin, mingw, BeOS.
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
Gnulib provides a module @code{get_date} that contains a function
|
Gnulib provides a module @code{parse-datetime} that contains a function
|
||||||
@code{get_date}
|
@code{parse_datetime}
|
||||||
that has similar functionality as the @code{getdate} function.
|
that has similar functionality as the @code{getdate} function.
|
||||||
|
@@ -5354,7 +5354,7 @@ func_create_testdir ()
|
|||||||
) || func_exit 1
|
) || func_exit 1
|
||||||
fi
|
fi
|
||||||
# Need to run configure and make once, to create built files that are to be
|
# 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'
|
sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
|
||||||
# Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
|
# Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
|
||||||
cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
|
cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
|
||||||
|
@@ -1,22 +1,3 @@
|
|||||||
/* Parse a string into an internal time stamp.
|
/* Obsolete; consider using parse-datetime.h instead. */
|
||||||
|
#include "parse-datetime.h"
|
||||||
Copyright (C) 1995, 1997, 1998, 2003, 2004, 2007, 2009, 2010 Free Software
|
#define get_date(a, b, c) parse_datetime (a, b, c)
|
||||||
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 *);
|
|
||||||
|
22
lib/parse-datetime.h
Normal file
22
lib/parse-datetime.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/* 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 *);
|
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "getdate.h"
|
#include "parse-datetime.h"
|
||||||
|
|
||||||
#include "intprops.h"
|
#include "intprops.h"
|
||||||
#include "timespec.h"
|
#include "timespec.h"
|
||||||
@@ -1201,7 +1201,8 @@ get_tz (char tzbuf[TZBUFSIZE])
|
|||||||
P can be an incomplete or relative time specification; if so, use
|
P can be an incomplete or relative time specification; if so, use
|
||||||
*NOW as the basis for the returned time. */
|
*NOW as the basis for the returned time. */
|
||||||
bool
|
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;
|
time_t Start;
|
||||||
long int Start_ns;
|
long int Start_ns;
|
||||||
@@ -1550,7 +1551,7 @@ main (int ac, char **av)
|
|||||||
{
|
{
|
||||||
struct timespec d;
|
struct timespec d;
|
||||||
struct tm const *tm;
|
struct tm const *tm;
|
||||||
if (! get_date (&d, buff, NULL))
|
if (! parse_datetime (&d, buff, NULL))
|
||||||
printf ("Bad format - couldn't convert.\n");
|
printf ("Bad format - couldn't convert.\n");
|
||||||
else if (! (tm = localtime (&d.tv_sec)))
|
else if (! (tm = localtime (&d.tv_sec)))
|
||||||
{
|
{
|
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
AC_DEFUN([gl_BISON],
|
AC_DEFUN([gl_BISON],
|
||||||
[
|
[
|
||||||
# get_date.y works with bison only.
|
# parse-datetime.y works with bison only.
|
||||||
: ${YACC='bison -y'}
|
: ${YACC='bison -y'}
|
||||||
dnl
|
dnl
|
||||||
dnl Declaring YACC & YFLAGS precious will not be necessary after GNULIB
|
dnl Declaring YACC & YFLAGS precious will not be necessary after GNULIB
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# get_date.m4 serial 17
|
# parse-datetime.m4 serial 18
|
||||||
dnl Copyright (C) 2002-2006, 2008-2010 Free Software Foundation, Inc.
|
dnl Copyright (C) 2002-2006, 2008-2010 Free Software Foundation, Inc.
|
||||||
dnl This file is free software; the Free Software Foundation
|
dnl This file is free software; the Free Software Foundation
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
dnl gives unlimited permission to copy and/or distribute it,
|
||||||
@@ -24,13 +24,13 @@ AC_DEFUN([gl_C_COMPOUND_LITERALS],
|
|||||||
fi
|
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([AM_STDBOOL_H])
|
||||||
AC_REQUIRE([gl_TIMESPEC])
|
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_BISON])
|
||||||
AC_REQUIRE([gl_C_COMPOUND_LITERALS])
|
AC_REQUIRE([gl_C_COMPOUND_LITERALS])
|
||||||
AC_STRUCT_TIMEZONE
|
AC_STRUCT_TIMEZONE
|
@@ -1,52 +0,0 @@
|
|||||||
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
|
|
@@ -1,14 +0,0 @@
|
|||||||
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)
|
|
@@ -5,12 +5,14 @@ Status:
|
|||||||
obsolete
|
obsolete
|
||||||
|
|
||||||
Notice:
|
Notice:
|
||||||
This module is obsolete. Use the module 'get_date' instead.
|
This module is obsolete. Use the module 'parse-datetime' instead.
|
||||||
|
|
||||||
Files:
|
Files:
|
||||||
|
doc/getdate.texi
|
||||||
|
lib/getdate.h
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
get_date
|
parse-datetime
|
||||||
|
|
||||||
configure.ac:
|
configure.ac:
|
||||||
|
|
||||||
|
52
modules/parse-datetime
Normal file
52
modules/parse-datetime
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
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
|
14
modules/parse-datetime-tests
Normal file
14
modules/parse-datetime-tests
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
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)
|
@@ -1,4 +1,4 @@
|
|||||||
/* Test of getdate() function.
|
/* Test of parse_datetime() function.
|
||||||
Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
|
Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "getdate.h"
|
#include "parse-datetime.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -62,14 +62,14 @@ main (int argc _GL_UNUSED, char **argv)
|
|||||||
now.tv_sec = 4711;
|
now.tv_sec = 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
p = "now";
|
p = "now";
|
||||||
ASSERT (get_date (&result, p, &now));
|
ASSERT (parse_datetime (&result, p, &now));
|
||||||
LOG (p, now, result);
|
LOG (p, now, result);
|
||||||
ASSERT (now.tv_sec == result.tv_sec && now.tv_nsec == result.tv_nsec);
|
ASSERT (now.tv_sec == result.tv_sec && now.tv_nsec == result.tv_nsec);
|
||||||
|
|
||||||
now.tv_sec = 4711;
|
now.tv_sec = 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
p = "tomorrow";
|
p = "tomorrow";
|
||||||
ASSERT (get_date (&result, p, &now));
|
ASSERT (parse_datetime (&result, p, &now));
|
||||||
LOG (p, now, result);
|
LOG (p, now, result);
|
||||||
ASSERT (now.tv_sec + 24 * 60 * 60 == result.tv_sec
|
ASSERT (now.tv_sec + 24 * 60 * 60 == result.tv_sec
|
||||||
&& now.tv_nsec == result.tv_nsec);
|
&& now.tv_nsec == result.tv_nsec);
|
||||||
@@ -77,7 +77,7 @@ main (int argc _GL_UNUSED, char **argv)
|
|||||||
now.tv_sec = 4711;
|
now.tv_sec = 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
p = "yesterday";
|
p = "yesterday";
|
||||||
ASSERT (get_date (&result, p, &now));
|
ASSERT (parse_datetime (&result, p, &now));
|
||||||
LOG (p, now, result);
|
LOG (p, now, result);
|
||||||
ASSERT (now.tv_sec - 24 * 60 * 60 == result.tv_sec
|
ASSERT (now.tv_sec - 24 * 60 * 60 == result.tv_sec
|
||||||
&& now.tv_nsec == result.tv_nsec);
|
&& now.tv_nsec == result.tv_nsec);
|
||||||
@@ -85,7 +85,7 @@ main (int argc _GL_UNUSED, char **argv)
|
|||||||
now.tv_sec = 4711;
|
now.tv_sec = 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
p = "4 hours";
|
p = "4 hours";
|
||||||
ASSERT (get_date (&result, p, &now));
|
ASSERT (parse_datetime (&result, p, &now));
|
||||||
LOG (p, now, result);
|
LOG (p, now, result);
|
||||||
ASSERT (now.tv_sec + 4 * 60 * 60 == result.tv_sec
|
ASSERT (now.tv_sec + 4 * 60 * 60 == result.tv_sec
|
||||||
&& now.tv_nsec == result.tv_nsec);
|
&& now.tv_nsec == result.tv_nsec);
|
||||||
@@ -94,10 +94,10 @@ main (int argc _GL_UNUSED, char **argv)
|
|||||||
now.tv_sec = 4711;
|
now.tv_sec = 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
p = "UTC+400 +24 hours";
|
p = "UTC+400 +24 hours";
|
||||||
ASSERT (get_date (&result, p, &now));
|
ASSERT (parse_datetime (&result, p, &now));
|
||||||
LOG (p, now, result);
|
LOG (p, now, result);
|
||||||
p = "UTC+400 +1 day";
|
p = "UTC+400 +1 day";
|
||||||
ASSERT (get_date (&result2, p, &now));
|
ASSERT (parse_datetime (&result2, p, &now));
|
||||||
LOG (p, now, result2);
|
LOG (p, now, result2);
|
||||||
ASSERT (result.tv_sec == result2.tv_sec
|
ASSERT (result.tv_sec == result2.tv_sec
|
||||||
&& result.tv_nsec == result2.tv_nsec);
|
&& result.tv_nsec == result2.tv_nsec);
|
||||||
@@ -106,15 +106,15 @@ main (int argc _GL_UNUSED, char **argv)
|
|||||||
now.tv_sec = 4711;
|
now.tv_sec = 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
p = "UTC+14:00";
|
p = "UTC+14:00";
|
||||||
ASSERT (get_date (&result, p, &now));
|
ASSERT (parse_datetime (&result, p, &now));
|
||||||
LOG (p, now, result);
|
LOG (p, now, result);
|
||||||
p = "UTC+14";
|
p = "UTC+14";
|
||||||
ASSERT (get_date (&result2, p, &now));
|
ASSERT (parse_datetime (&result2, p, &now));
|
||||||
LOG (p, now, result2);
|
LOG (p, now, result2);
|
||||||
ASSERT (result.tv_sec == result2.tv_sec
|
ASSERT (result.tv_sec == result2.tv_sec
|
||||||
&& result.tv_nsec == result2.tv_nsec);
|
&& result.tv_nsec == result2.tv_nsec);
|
||||||
p = "UTC+1400";
|
p = "UTC+1400";
|
||||||
ASSERT (get_date (&result2, p, &now));
|
ASSERT (parse_datetime (&result2, p, &now));
|
||||||
LOG (p, now, result2);
|
LOG (p, now, result2);
|
||||||
ASSERT (result.tv_sec == result2.tv_sec
|
ASSERT (result.tv_sec == result2.tv_sec
|
||||||
&& result.tv_nsec == result2.tv_nsec);
|
&& result.tv_nsec == result2.tv_nsec);
|
||||||
@@ -122,15 +122,15 @@ main (int argc _GL_UNUSED, char **argv)
|
|||||||
now.tv_sec = 4711;
|
now.tv_sec = 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
p = "UTC-14:00";
|
p = "UTC-14:00";
|
||||||
ASSERT (get_date (&result, p, &now));
|
ASSERT (parse_datetime (&result, p, &now));
|
||||||
LOG (p, now, result);
|
LOG (p, now, result);
|
||||||
p = "UTC-14";
|
p = "UTC-14";
|
||||||
ASSERT (get_date (&result2, p, &now));
|
ASSERT (parse_datetime (&result2, p, &now));
|
||||||
LOG (p, now, result2);
|
LOG (p, now, result2);
|
||||||
ASSERT (result.tv_sec == result2.tv_sec
|
ASSERT (result.tv_sec == result2.tv_sec
|
||||||
&& result.tv_nsec == result2.tv_nsec);
|
&& result.tv_nsec == result2.tv_nsec);
|
||||||
p = "UTC-1400";
|
p = "UTC-1400";
|
||||||
ASSERT (get_date (&result2, p, &now));
|
ASSERT (parse_datetime (&result2, p, &now));
|
||||||
LOG (p, now, result2);
|
LOG (p, now, result2);
|
||||||
ASSERT (result.tv_sec == result2.tv_sec
|
ASSERT (result.tv_sec == result2.tv_sec
|
||||||
&& result.tv_nsec == result2.tv_nsec);
|
&& result.tv_nsec == result2.tv_nsec);
|
||||||
@@ -138,10 +138,10 @@ main (int argc _GL_UNUSED, char **argv)
|
|||||||
now.tv_sec = 4711;
|
now.tv_sec = 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
p = "UTC+0:15";
|
p = "UTC+0:15";
|
||||||
ASSERT (get_date (&result, p, &now));
|
ASSERT (parse_datetime (&result, p, &now));
|
||||||
LOG (p, now, result);
|
LOG (p, now, result);
|
||||||
p = "UTC+0015";
|
p = "UTC+0015";
|
||||||
ASSERT (get_date (&result2, p, &now));
|
ASSERT (parse_datetime (&result2, p, &now));
|
||||||
LOG (p, now, result2);
|
LOG (p, now, result2);
|
||||||
ASSERT (result.tv_sec == result2.tv_sec
|
ASSERT (result.tv_sec == result2.tv_sec
|
||||||
&& result.tv_nsec == result2.tv_nsec);
|
&& result.tv_nsec == result2.tv_nsec);
|
||||||
@@ -149,65 +149,65 @@ main (int argc _GL_UNUSED, char **argv)
|
|||||||
now.tv_sec = 4711;
|
now.tv_sec = 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
p = "UTC-1:30";
|
p = "UTC-1:30";
|
||||||
ASSERT (get_date (&result, p, &now));
|
ASSERT (parse_datetime (&result, p, &now));
|
||||||
LOG (p, now, result);
|
LOG (p, now, result);
|
||||||
p = "UTC-130";
|
p = "UTC-130";
|
||||||
ASSERT (get_date (&result2, p, &now));
|
ASSERT (parse_datetime (&result2, p, &now));
|
||||||
LOG (p, now, result2);
|
LOG (p, now, result2);
|
||||||
ASSERT (result.tv_sec == result2.tv_sec
|
ASSERT (result.tv_sec == result2.tv_sec
|
||||||
&& result.tv_nsec == result2.tv_nsec);
|
&& 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_sec = 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
p = "UTC+25:00";
|
p = "UTC+25:00";
|
||||||
ASSERT (!get_date (&result, p, &now));
|
ASSERT (!parse_datetime (&result, p, &now));
|
||||||
|
|
||||||
/* Check for several invalid countable dayshifts */
|
/* Check for several invalid countable dayshifts */
|
||||||
now.tv_sec = 4711;
|
now.tv_sec = 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
p = "UTC+4:00 +40 yesterday";
|
p = "UTC+4:00 +40 yesterday";
|
||||||
ASSERT (!get_date (&result, p, &now));
|
ASSERT (!parse_datetime (&result, p, &now));
|
||||||
p = "UTC+4:00 next yesterday";
|
p = "UTC+4:00 next yesterday";
|
||||||
ASSERT (!get_date (&result, p, &now));
|
ASSERT (!parse_datetime (&result, p, &now));
|
||||||
p = "UTC+4:00 tomorrow ago";
|
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";
|
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";
|
p = "UTC+4:00 last tomorrow";
|
||||||
ASSERT (!get_date (&result, p, &now));
|
ASSERT (!parse_datetime (&result, p, &now));
|
||||||
p = "UTC+4:00 -4 today";
|
p = "UTC+4:00 -4 today";
|
||||||
ASSERT (!get_date (&result, p, &now));
|
ASSERT (!parse_datetime (&result, p, &now));
|
||||||
|
|
||||||
/* And check correct usage of dayshifts */
|
/* And check correct usage of dayshifts */
|
||||||
now.tv_sec = 4711;
|
now.tv_sec = 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
p = "UTC+400 tomorrow";
|
p = "UTC+400 tomorrow";
|
||||||
ASSERT (get_date (&result, p, &now));
|
ASSERT (parse_datetime (&result, p, &now));
|
||||||
LOG (p, now, result);
|
LOG (p, now, result);
|
||||||
p = "UTC+400 +1 day";
|
p = "UTC+400 +1 day";
|
||||||
ASSERT (get_date (&result2, p, &now));
|
ASSERT (parse_datetime (&result2, p, &now));
|
||||||
LOG (p, now, result2);
|
LOG (p, now, result2);
|
||||||
ASSERT (result.tv_sec == result2.tv_sec
|
ASSERT (result.tv_sec == result2.tv_sec
|
||||||
&& result.tv_nsec == result2.tv_nsec);
|
&& result.tv_nsec == result2.tv_nsec);
|
||||||
now.tv_sec = 4711;
|
now.tv_sec = 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
p = "UTC+400 yesterday";
|
p = "UTC+400 yesterday";
|
||||||
ASSERT (get_date (&result, p, &now));
|
ASSERT (parse_datetime (&result, p, &now));
|
||||||
LOG (p, now, result);
|
LOG (p, now, result);
|
||||||
p = "UTC+400 1 day ago";
|
p = "UTC+400 1 day ago";
|
||||||
ASSERT (get_date (&result2, p, &now));
|
ASSERT (parse_datetime (&result2, p, &now));
|
||||||
LOG (p, now, result2);
|
LOG (p, now, result2);
|
||||||
ASSERT (result.tv_sec == result2.tv_sec
|
ASSERT (result.tv_sec == result2.tv_sec
|
||||||
&& result.tv_nsec == result2.tv_nsec);
|
&& result.tv_nsec == result2.tv_nsec);
|
||||||
now.tv_sec = 4711;
|
now.tv_sec = 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
p = "UTC+400 now";
|
p = "UTC+400 now";
|
||||||
ASSERT (get_date (&result, p, &now));
|
ASSERT (parse_datetime (&result, p, &now));
|
||||||
LOG (p, now, result);
|
LOG (p, now, result);
|
||||||
p = "UTC+400 +0 minutes"; /* silly, but simple "UTC+400" is different*/
|
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);
|
LOG (p, now, result2);
|
||||||
ASSERT (result.tv_sec == result2.tv_sec
|
ASSERT (result.tv_sec == result2.tv_sec
|
||||||
&& result.tv_nsec == result2.tv_nsec);
|
&& result.tv_nsec == result2.tv_nsec);
|
||||||
@@ -221,7 +221,7 @@ main (int argc _GL_UNUSED, char **argv)
|
|||||||
sprintf (tmp, "NEXT %s", day_table[i]);
|
sprintf (tmp, "NEXT %s", day_table[i]);
|
||||||
now.tv_sec = thur2 + 4711;
|
now.tv_sec = thur2 + 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
ASSERT (get_date (&result, tmp, &now));
|
ASSERT (parse_datetime (&result, tmp, &now));
|
||||||
LOG (tmp, now, result);
|
LOG (tmp, now, result);
|
||||||
ASSERT (result.tv_nsec == 0);
|
ASSERT (result.tv_nsec == 0);
|
||||||
ASSERT (result.tv_sec == thur2 + (i == 4 ? 7 : (i + 3) % 7) * 24 * 3600);
|
ASSERT (result.tv_sec == thur2 + (i == 4 ? 7 : (i + 3) % 7) * 24 * 3600);
|
||||||
@@ -229,7 +229,7 @@ main (int argc _GL_UNUSED, char **argv)
|
|||||||
sprintf (tmp, "LAST %s", day_table[i]);
|
sprintf (tmp, "LAST %s", day_table[i]);
|
||||||
now.tv_sec = thur2 + 4711;
|
now.tv_sec = thur2 + 4711;
|
||||||
now.tv_nsec = 1267;
|
now.tv_nsec = 1267;
|
||||||
ASSERT (get_date (&result, tmp, &now));
|
ASSERT (parse_datetime (&result, tmp, &now));
|
||||||
LOG (tmp, now, result);
|
LOG (tmp, now, result);
|
||||||
ASSERT (result.tv_nsec == 0);
|
ASSERT (result.tv_nsec == 0);
|
||||||
ASSERT (result.tv_sec == thur2 + ((i + 3) % 7 - 7) * 24 * 3600);
|
ASSERT (result.tv_sec == thur2 + ((i + 3) % 7 - 7) * 24 * 3600);
|
||||||
@@ -238,7 +238,7 @@ main (int argc _GL_UNUSED, char **argv)
|
|||||||
p = "THURSDAY UTC+00"; /* The epoch was on Thursday. */
|
p = "THURSDAY UTC+00"; /* The epoch was on Thursday. */
|
||||||
now.tv_sec = 0;
|
now.tv_sec = 0;
|
||||||
now.tv_nsec = 0;
|
now.tv_nsec = 0;
|
||||||
ASSERT (get_date (&result, p, &now));
|
ASSERT (parse_datetime (&result, p, &now));
|
||||||
LOG (p, now, result);
|
LOG (p, now, result);
|
||||||
ASSERT (result.tv_sec == now.tv_sec
|
ASSERT (result.tv_sec == now.tv_sec
|
||||||
&& result.tv_nsec == now.tv_nsec);
|
&& result.tv_nsec == now.tv_nsec);
|
||||||
@@ -246,7 +246,7 @@ main (int argc _GL_UNUSED, char **argv)
|
|||||||
p = "FRIDAY UTC+00";
|
p = "FRIDAY UTC+00";
|
||||||
now.tv_sec = 0;
|
now.tv_sec = 0;
|
||||||
now.tv_nsec = 0;
|
now.tv_nsec = 0;
|
||||||
ASSERT (get_date (&result, p, &now));
|
ASSERT (parse_datetime (&result, p, &now));
|
||||||
LOG (p, now, result);
|
LOG (p, now, result);
|
||||||
ASSERT (result.tv_sec == 24 * 3600
|
ASSERT (result.tv_sec == 24 * 3600
|
||||||
&& result.tv_nsec == now.tv_nsec);
|
&& result.tv_nsec == now.tv_nsec);
|
Reference in New Issue
Block a user