1 /* A Bison parser, made by GNU Bison 2.3. */
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
23 /* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
39 /* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
46 /* Identify Bison output. */
50 #define YYBISON_VERSION "2.3"
53 #define YYSKELETON_NAME "yacc.c"
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
66 /* Put the tokens into the symbol table, so that GDB and other debuggers
87 tSDECIMAL_NUMBER = 276,
88 tUDECIMAL_NUMBER = 277
94 #define tYEAR_UNIT 260
95 #define tMONTH_UNIT 261
96 #define tHOUR_UNIT 262
97 #define tMINUTE_UNIT 263
100 #define tDAY_SHIFT 266
103 #define tLOCAL_ZONE 269
104 #define tMERIDIAN 270
110 #define tSDECIMAL_NUMBER 276
111 #define tUDECIMAL_NUMBER 277
116 /* Copy the first part of user declarations. */
119 /* Parse a string into an internal time stamp.
121 Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008
122 Free Software Foundation, Inc.
124 This program is free software: you can redistribute it and/or modify
125 it under the terms of the GNU General Public License as published by
126 the Free Software Foundation; either version 3 of the License, or
127 (at your option) any later version.
129 This program is distributed in the hope that it will be useful,
130 but WITHOUT ANY WARRANTY; without even the implied warranty of
131 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
132 GNU General Public License for more details.
134 You should have received a copy of the GNU General Public License
135 along with this program. If not, see <http://www.gnu.org/licenses/>. */
137 /* Originally written by Steven M. Bellovin <smb@research.att.com> while
138 at the University of North Carolina at Chapel Hill. Later tweaked by
139 a couple of people on Usenet. Completely overhauled by Rich $alz
140 <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990.
142 Modified by Paul Eggert <eggert@twinsun.com> in August 1999 to do
143 the right thing about local DST. Also modified by Paul Eggert
144 <eggert@cs.ucla.edu> in February 2004 to support
145 nanosecond-resolution time stamps, and in October 2004 to support
146 TZ strings in dates. */
148 /* FIXME: Check for arithmetic overflow in all cases, not just
155 #include "intprops.h"
156 #include "timespec.h"
159 /* There's no need to extend the stack, so there's no need to involve
161 #define YYSTACK_USE_ALLOCA 0
163 /* Tell Bison how much stack space is needed. 20 should be plenty for
164 this grammar, which is not right recursive. Beware setting it too
165 high, since that might cause problems on machines whose
166 implementations have lame stack-overflow checking. */
167 #define YYMAXDEPTH 20
168 #define YYINITDEPTH YYMAXDEPTH
170 /* Since the code of getdate.y is not included in the Emacs executable
171 itself, there is no need to #define static in this file. Even if
172 the code were included in the Emacs executable, it probably
173 wouldn't do any harm to #undef it here; this will only cause
174 problems if we try to write to a static variable, which I don't
175 think this code needs to do. */
189 /* ISDIGIT differs from isdigit, as follows:
190 - Its arg may be any int or unsigned int; it need not be an unsigned char
192 - It's typically faster.
193 POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
194 isdigit unless it's important to use the locale's definition
195 of `digit' even when the host does not conform to POSIX. */
196 #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
198 #ifndef __attribute__
199 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
200 # define __attribute__(x)
204 #ifndef ATTRIBUTE_UNUSED
205 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
208 /* Shift A right by B bits portably, by dividing A by 2**B and
209 truncating towards minus infinity. A and B should be free of side
210 effects, and B should be in the range 0 <= B <= INT_BITS - 2, where
211 INT_BITS is the number of useful bits in an int. GNU code can
212 assume that INT_BITS is at least 32.
214 ISO C99 says that A >> B is implementation-defined if A < 0. Some
215 implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift
216 right in the usual way when A < 0, so SHR falls back on division if
217 ordinary A >> B doesn't seem to be the usual signed shift. */
221 : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
223 #define EPOCH_YEAR 1970
224 #define TM_YEAR_BASE 1900
226 #define HOUR(x) ((x) * 60)
228 /* Lots of this code assumes time_t and time_t-like values fit into
229 long int. It also assumes that signed integer overflow silently
230 wraps around, but there's no portable way to check for that at
232 verify (TYPE_IS_INTEGER (time_t));
233 verify (LONG_MIN <= TYPE_MINIMUM (time_t) && TYPE_MAXIMUM (time_t) <= LONG_MAX);
235 /* An integer value, and the number of digits in its textual
244 /* An entry in the lexical lookup table. */
252 /* Meridian: am, pm, or 24-hour style. */
253 enum { MERam, MERpm, MER24 };
255 enum { BILLION = 1000000000, LOG10_BILLION = 9 };
257 /* Relative times. */
260 /* Relative year, month, day, hour, minutes, seconds, and nanoseconds. */
270 #if HAVE_COMPOUND_LITERALS
271 # define RELATIVE_TIME_0 ((relative_time) { 0, 0, 0, 0, 0, 0, 0 })
273 static relative_time const RELATIVE_TIME_0;
276 /* Information passed to and from the parser. */
279 /* The input string remaining to be parsed. */
282 /* N, if this is the Nth Tuesday. */
283 long int day_ordinal;
285 /* Day of week; Sunday is 0. */
288 /* tm_isdst flag for the local zone. */
291 /* Time zone, in minutes east of UTC. */
294 /* Style used for time. */
297 /* Gregorian year, month, day, hour, minutes, seconds, and nanoseconds. */
303 struct timespec seconds; /* includes nanoseconds */
305 /* Relative year, month, day, hour, minutes, seconds, and nanoseconds. */
308 /* Presence or counts of nonterminals of various flavors parsed so far. */
313 size_t local_zones_seen;
318 /* Table of local time zone abbrevations, terminated by a null entry. */
319 table local_time_zone_table[3];
323 static int yylex (union YYSTYPE *, parser_control *);
324 static int yyerror (parser_control const *, char const *);
325 static long int time_zone_hhmm (parser_control *, textint, long int);
327 /* Extract into *PC any date and time info from a string of digits
328 of the form e.g., YYYYMMDD, YYMMDD, HHMM, HH (and sometimes YYY,
331 digits_to_date_time (parser_control *pc, textint text_int)
333 if (pc->dates_seen && ! pc->year.digits
334 && ! pc->rels_seen && (pc->times_seen || 2 < text_int.digits))
338 if (4 < text_int.digits)
341 pc->day = text_int.value % 100;
342 pc->month = (text_int.value / 100) % 100;
343 pc->year.value = text_int.value / 10000;
344 pc->year.digits = text_int.digits - 4;
349 if (text_int.digits <= 2)
351 pc->hour = text_int.value;
356 pc->hour = text_int.value / 100;
357 pc->minutes = text_int.value % 100;
359 pc->seconds.tv_sec = 0;
360 pc->seconds.tv_nsec = 0;
361 pc->meridian = MER24;
366 /* Increment PC->rel by FACTOR * REL (FACTOR is 1 or -1). */
368 apply_relative_time (parser_control *pc, relative_time rel, int factor)
370 pc->rel.ns += factor * rel.ns;
371 pc->rel.seconds += factor * rel.seconds;
372 pc->rel.minutes += factor * rel.minutes;
373 pc->rel.hour += factor * rel.hour;
374 pc->rel.day += factor * rel.day;
375 pc->rel.month += factor * rel.month;
376 pc->rel.year += factor * rel.year;
377 pc->rels_seen = true;
380 /* Set PC-> hour, minutes, seconds and nanoseconds members from arguments. */
382 set_hhmmss (parser_control *pc, long int hour, long int minutes,
383 time_t sec, long int nsec)
386 pc->minutes = minutes;
387 pc->seconds.tv_sec = sec;
388 pc->seconds.tv_nsec = nsec;
393 /* Enabling traces. */
398 /* Enabling verbose error messages. */
399 #ifdef YYERROR_VERBOSE
400 # undef YYERROR_VERBOSE
401 # define YYERROR_VERBOSE 1
403 # define YYERROR_VERBOSE 0
406 /* Enabling the token table. */
407 #ifndef YYTOKEN_TABLE
408 # define YYTOKEN_TABLE 0
411 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
412 typedef union YYSTYPE
413 #line 286 "getdate.y"
417 struct timespec timespec;
420 /* Line 187 of yacc.c. */
421 #line 422 "getdate.c"
423 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
424 # define YYSTYPE_IS_DECLARED 1
425 # define YYSTYPE_IS_TRIVIAL 1
430 /* Copy the second part of user declarations. */
433 /* Line 216 of yacc.c. */
434 #line 435 "getdate.c"
441 typedef YYTYPE_UINT8 yytype_uint8;
443 typedef unsigned char yytype_uint8;
447 typedef YYTYPE_INT8 yytype_int8;
448 #elif (defined __STDC__ || defined __C99__FUNC__ \
449 || defined __cplusplus || defined _MSC_VER)
450 typedef signed char yytype_int8;
452 typedef short int yytype_int8;
456 typedef YYTYPE_UINT16 yytype_uint16;
458 typedef unsigned short int yytype_uint16;
462 typedef YYTYPE_INT16 yytype_int16;
464 typedef short int yytype_int16;
468 # ifdef __SIZE_TYPE__
469 # define YYSIZE_T __SIZE_TYPE__
470 # elif defined size_t
471 # define YYSIZE_T size_t
472 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
473 || defined __cplusplus || defined _MSC_VER)
474 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
475 # define YYSIZE_T size_t
477 # define YYSIZE_T unsigned int
481 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
486 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
487 # define YY_(msgid) dgettext ("bison-runtime", msgid)
491 # define YY_(msgid) msgid
495 /* Suppress unused-variable warnings by "using" E. */
496 #if ! defined lint || defined __GNUC__
497 # define YYUSE(e) ((void) (e))
499 # define YYUSE(e) /* empty */
502 /* Identity function, used to suppress warnings about constant conditions. */
506 #if (defined __STDC__ || defined __C99__FUNC__ \
507 || defined __cplusplus || defined _MSC_VER)
520 #if ! defined yyoverflow || YYERROR_VERBOSE
522 /* The parser invokes alloca or malloc; define the necessary symbols. */
524 # ifdef YYSTACK_USE_ALLOCA
525 # if YYSTACK_USE_ALLOCA
527 # define YYSTACK_ALLOC __builtin_alloca
528 # elif defined __BUILTIN_VA_ARG_INCR
529 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
531 # define YYSTACK_ALLOC __alloca
532 # elif defined _MSC_VER
533 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
534 # define alloca _alloca
536 # define YYSTACK_ALLOC alloca
537 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
538 || defined __cplusplus || defined _MSC_VER)
539 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
548 # ifdef YYSTACK_ALLOC
549 /* Pacify GCC's `empty if-body' warning. */
550 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
551 # ifndef YYSTACK_ALLOC_MAXIMUM
552 /* The OS might guarantee only one guard page at the bottom of the stack,
553 and a page size can be as small as 4096 bytes. So we cannot safely
554 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
555 to allow for a few compiler-allocated temporary stack slots. */
556 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
559 # define YYSTACK_ALLOC YYMALLOC
560 # define YYSTACK_FREE YYFREE
561 # ifndef YYSTACK_ALLOC_MAXIMUM
562 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
564 # if (defined __cplusplus && ! defined _STDLIB_H \
565 && ! ((defined YYMALLOC || defined malloc) \
566 && (defined YYFREE || defined free)))
567 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
573 # define YYMALLOC malloc
574 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
575 || defined __cplusplus || defined _MSC_VER)
576 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
581 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
582 || defined __cplusplus || defined _MSC_VER)
583 void free (void *); /* INFRINGES ON USER NAME SPACE */
587 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
590 #if (! defined yyoverflow \
591 && (! defined __cplusplus \
592 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
594 /* A type that is properly aligned for any stack member. */
601 /* The size of the maximum gap between one aligned stack and the next. */
602 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
604 /* The size of an array large to enough to hold all stacks, each with
606 # define YYSTACK_BYTES(N) \
607 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
608 + YYSTACK_GAP_MAXIMUM)
610 /* Copy COUNT objects from FROM to TO. The source and destination do
613 # if defined __GNUC__ && 1 < __GNUC__
614 # define YYCOPY(To, From, Count) \
615 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
617 # define YYCOPY(To, From, Count) \
621 for (yyi = 0; yyi < (Count); yyi++) \
622 (To)[yyi] = (From)[yyi]; \
628 /* Relocate STACK from its old location to the new one. The
629 local variables YYSIZE and YYSTACKSIZE give the old and new number of
630 elements in the stack, and YYPTR gives the new location of the
631 stack. Advance YYPTR to a properly aligned location for the next
633 # define YYSTACK_RELOCATE(Stack) \
636 YYSIZE_T yynewbytes; \
637 YYCOPY (&yyptr->Stack, Stack, yysize); \
638 Stack = &yyptr->Stack; \
639 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
640 yyptr += yynewbytes / sizeof (*yyptr); \
646 /* YYFINAL -- State number of the termination state. */
648 /* YYLAST -- Last index in YYTABLE. */
651 /* YYNTOKENS -- Number of terminals. */
653 /* YYNNTS -- Number of nonterminals. */
655 /* YYNRULES -- Number of rules. */
657 /* YYNRULES -- Number of states. */
658 #define YYNSTATES 100
660 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
662 #define YYMAXUTOK 277
664 #define YYTRANSLATE(YYX) \
665 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
667 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
668 static const yytype_uint8 yytranslate[] =
670 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
671 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
672 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
673 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
674 2, 2, 2, 2, 25, 2, 2, 26, 2, 2,
675 2, 2, 2, 2, 2, 2, 2, 2, 24, 2,
676 2, 2, 2, 2, 23, 2, 2, 2, 2, 2,
677 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
678 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
679 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
680 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
681 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
682 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
683 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
684 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
685 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
686 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
687 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
688 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
689 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
690 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
691 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
692 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
693 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
694 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
695 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
696 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
697 15, 16, 17, 18, 19, 20, 21, 22
701 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
703 static const yytype_uint8 yyprhs[] =
705 0, 0, 3, 5, 7, 10, 11, 14, 16, 18,
706 20, 22, 24, 26, 28, 30, 33, 38, 44, 51,
707 59, 61, 64, 66, 69, 73, 75, 78, 80, 83,
708 86, 89, 93, 99, 103, 107, 111, 114, 119, 122,
709 126, 129, 131, 133, 136, 139, 141, 144, 147, 149,
710 152, 155, 157, 160, 163, 165, 168, 171, 173, 176,
711 179, 182, 185, 187, 189, 192, 195, 198, 201, 204,
712 207, 209, 211, 213, 215, 217, 219, 221, 223, 226,
716 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
717 static const yytype_int8 yyrhs[] =
719 28, 0, -1, 29, -1, 30, -1, 23, 41, -1,
720 -1, 30, 31, -1, 32, -1, 33, -1, 34, -1,
721 36, -1, 35, -1, 37, -1, 44, -1, 45, -1,
722 20, 15, -1, 20, 24, 20, 47, -1, 20, 24,
723 20, 19, 46, -1, 20, 24, 20, 24, 43, 47,
724 -1, 20, 24, 20, 24, 43, 19, 46, -1, 14,
725 -1, 14, 4, -1, 18, -1, 18, 39, -1, 18,
726 19, 46, -1, 13, -1, 18, 4, -1, 12, -1,
727 12, 25, -1, 17, 12, -1, 20, 12, -1, 20,
728 26, 20, -1, 20, 26, 20, 26, 20, -1, 20,
729 19, 19, -1, 20, 16, 19, -1, 16, 19, 19,
730 -1, 16, 20, -1, 16, 20, 25, 20, -1, 20,
731 16, -1, 20, 16, 20, -1, 38, 3, -1, 38,
732 -1, 40, -1, 17, 5, -1, 20, 5, -1, 5,
733 -1, 17, 6, -1, 20, 6, -1, 6, -1, 17,
734 10, -1, 20, 10, -1, 10, -1, 17, 7, -1,
735 20, 7, -1, 7, -1, 17, 8, -1, 20, 8,
736 -1, 8, -1, 17, 9, -1, 20, 9, -1, 21,
737 9, -1, 22, 9, -1, 9, -1, 39, -1, 19,
738 5, -1, 19, 6, -1, 19, 10, -1, 19, 7,
739 -1, 19, 8, -1, 19, 9, -1, 11, -1, 42,
740 -1, 43, -1, 21, -1, 19, -1, 22, -1, 20,
741 -1, 20, -1, 20, 39, -1, -1, 24, 20, -1,
745 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
746 static const yytype_uint16 yyrline[] =
748 0, 312, 312, 313, 317, 324, 326, 330, 332, 334,
749 336, 338, 340, 341, 342, 346, 351, 356, 363, 368,
750 378, 383, 391, 393, 396, 398, 400, 405, 410, 415,
751 420, 428, 433, 453, 460, 468, 476, 481, 487, 492,
752 501, 503, 505, 510, 512, 514, 516, 518, 520, 522,
753 524, 526, 528, 530, 532, 534, 536, 538, 540, 542,
754 544, 546, 548, 550, 554, 556, 558, 560, 562, 564,
755 569, 573, 573, 576, 577, 582, 583, 588, 593, 604,
760 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
761 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
762 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
763 static const char *const yytname[] =
765 "$end", "error", "$undefined", "tAGO", "tDST", "tYEAR_UNIT",
766 "tMONTH_UNIT", "tHOUR_UNIT", "tMINUTE_UNIT", "tSEC_UNIT", "tDAY_UNIT",
767 "tDAY_SHIFT", "tDAY", "tDAYZONE", "tLOCAL_ZONE", "tMERIDIAN", "tMONTH",
768 "tORDINAL", "tZONE", "tSNUMBER", "tUNUMBER", "tSDECIMAL_NUMBER",
769 "tUDECIMAL_NUMBER", "'@'", "':'", "','", "'/'", "$accept", "spec",
770 "timespec", "items", "item", "time", "local_zone", "zone", "day", "date",
771 "rel", "relunit", "relunit_snumber", "dayshift", "seconds",
772 "signed_seconds", "unsigned_seconds", "number", "hybrid",
773 "o_colon_minutes", "o_merid", 0
778 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
780 static const yytype_uint16 yytoknum[] =
782 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
783 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
784 275, 276, 277, 64, 58, 44, 47
788 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
789 static const yytype_uint8 yyr1[] =
791 0, 27, 28, 28, 29, 30, 30, 31, 31, 31,
792 31, 31, 31, 31, 31, 32, 32, 32, 32, 32,
793 33, 33, 34, 34, 34, 34, 34, 35, 35, 35,
794 35, 36, 36, 36, 36, 36, 36, 36, 36, 36,
795 37, 37, 37, 38, 38, 38, 38, 38, 38, 38,
796 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
797 38, 38, 38, 38, 39, 39, 39, 39, 39, 39,
798 40, 41, 41, 42, 42, 43, 43, 44, 45, 46,
802 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
803 static const yytype_uint8 yyr2[] =
805 0, 2, 1, 1, 2, 0, 2, 1, 1, 1,
806 1, 1, 1, 1, 1, 2, 4, 5, 6, 7,
807 1, 2, 1, 2, 3, 1, 2, 1, 2, 2,
808 2, 3, 5, 3, 3, 3, 2, 4, 2, 3,
809 2, 1, 1, 2, 2, 1, 2, 2, 1, 2,
810 2, 1, 2, 2, 1, 2, 2, 1, 2, 2,
811 2, 2, 1, 1, 2, 2, 2, 2, 2, 2,
812 1, 1, 1, 1, 1, 1, 1, 1, 2, 0,
816 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
817 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
818 means the default is an error. */
819 static const yytype_uint8 yydefact[] =
821 5, 0, 0, 2, 3, 74, 76, 73, 75, 4,
822 71, 72, 1, 45, 48, 54, 57, 62, 51, 70,
823 27, 25, 20, 0, 0, 22, 0, 77, 0, 0,
824 6, 7, 8, 9, 11, 10, 12, 41, 63, 42,
825 13, 14, 28, 21, 0, 36, 43, 46, 52, 55,
826 58, 49, 29, 26, 79, 23, 64, 65, 67, 68,
827 69, 66, 44, 47, 53, 56, 59, 50, 30, 15,
828 38, 0, 0, 0, 78, 60, 61, 40, 35, 0,
829 0, 24, 34, 39, 33, 81, 31, 37, 80, 82,
830 79, 0, 16, 0, 17, 81, 32, 79, 18, 19
833 /* YYDEFGOTO[NTERM-NUM]. */
834 static const yytype_int8 yydefgoto[] =
836 -1, 2, 3, 4, 30, 31, 32, 33, 34, 35,
837 36, 37, 38, 39, 9, 10, 11, 40, 41, 81,
841 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
843 #define YYPACT_NINF -82
844 static const yytype_int8 yypact[] =
846 -17, 56, 15, -82, 26, -82, -82, -82, -82, -82,
847 -82, -82, -82, -82, -82, -82, -82, -82, -82, -82,
848 36, -82, 68, 10, 50, 9, 59, -5, 72, 73,
849 -82, -82, -82, -82, -82, -82, -82, 80, -82, -82,
850 -82, -82, -82, -82, 65, 61, -82, -82, -82, -82,
851 -82, -82, -82, -82, 17, -82, -82, -82, -82, -82,
852 -82, -82, -82, -82, -82, -82, -82, -82, -82, -82,
853 60, 44, 67, 69, -82, -82, -82, -82, -82, 70,
854 71, -82, -82, -82, -82, -7, 62, -82, -82, -82,
855 74, -2, -82, 75, -82, 55, -82, 74, -82, -82
858 /* YYPGOTO[NTERM-NUM]. */
859 static const yytype_int8 yypgoto[] =
861 -82, -82, -82, -82, -82, -82, -82, -82, -82, -82,
862 -82, -82, 46, -82, -82, -82, -6, -82, -82, -81,
866 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
867 positive, shift that token. If negative, reduce the rule which
868 number is the opposite. If zero, do what YYDEFACT says.
869 If YYTABLE_NINF, syntax error. */
870 #define YYTABLE_NINF -1
871 static const yytype_uint8 yytable[] =
873 62, 63, 64, 65, 66, 67, 1, 68, 89, 94,
874 69, 70, 90, 53, 71, 12, 99, 91, 6, 72,
875 8, 73, 56, 57, 58, 59, 60, 61, 54, 44,
876 45, 13, 14, 15, 16, 17, 18, 19, 20, 21,
877 22, 80, 23, 24, 25, 26, 27, 28, 29, 56,
878 57, 58, 59, 60, 61, 46, 47, 48, 49, 50,
879 51, 42, 52, 84, 56, 57, 58, 59, 60, 61,
880 89, 55, 43, 74, 97, 5, 6, 7, 8, 82,
881 83, 75, 76, 77, 78, 95, 79, 85, 93, 86,
882 87, 88, 98, 0, 0, 96, 0, 0, 80
885 static const yytype_int8 yycheck[] =
887 5, 6, 7, 8, 9, 10, 23, 12, 15, 90,
888 15, 16, 19, 4, 19, 0, 97, 24, 20, 24,
889 22, 26, 5, 6, 7, 8, 9, 10, 19, 19,
890 20, 5, 6, 7, 8, 9, 10, 11, 12, 13,
891 14, 24, 16, 17, 18, 19, 20, 21, 22, 5,
892 6, 7, 8, 9, 10, 5, 6, 7, 8, 9,
893 10, 25, 12, 19, 5, 6, 7, 8, 9, 10,
894 15, 25, 4, 27, 19, 19, 20, 21, 22, 19,
895 20, 9, 9, 3, 19, 91, 25, 20, 26, 20,
896 20, 20, 95, -1, -1, 20, -1, -1, 24
899 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
900 symbol of state STATE-NUM. */
901 static const yytype_uint8 yystos[] =
903 0, 23, 28, 29, 30, 19, 20, 21, 22, 41,
904 42, 43, 0, 5, 6, 7, 8, 9, 10, 11,
905 12, 13, 14, 16, 17, 18, 19, 20, 21, 22,
906 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
907 44, 45, 25, 4, 19, 20, 5, 6, 7, 8,
908 9, 10, 12, 4, 19, 39, 5, 6, 7, 8,
909 9, 10, 5, 6, 7, 8, 9, 10, 12, 15,
910 16, 19, 24, 26, 39, 9, 9, 3, 19, 25,
911 24, 46, 19, 20, 19, 20, 20, 20, 20, 15,
912 19, 24, 47, 26, 46, 43, 20, 19, 47, 46
915 #define yyerrok (yyerrstatus = 0)
916 #define yyclearin (yychar = YYEMPTY)
920 #define YYACCEPT goto yyacceptlab
921 #define YYABORT goto yyabortlab
922 #define YYERROR goto yyerrorlab
925 /* Like YYERROR except do call yyerror. This remains here temporarily
926 to ease the transition to the new meaning of YYERROR, for GCC.
927 Once GCC version 2 has supplanted version 1, this can go. */
929 #define YYFAIL goto yyerrlab
931 #define YYRECOVERING() (!!yyerrstatus)
933 #define YYBACKUP(Token, Value) \
935 if (yychar == YYEMPTY && yylen == 1) \
939 yytoken = YYTRANSLATE (yychar); \
945 yyerror (pc, YY_("syntax error: cannot back up")); \
952 #define YYERRCODE 256
955 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
956 If N is 0, then set CURRENT to the empty location which ends
957 the previous symbol: RHS[0] (always defined). */
959 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
960 #ifndef YYLLOC_DEFAULT
961 # define YYLLOC_DEFAULT(Current, Rhs, N) \
965 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
966 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
967 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
968 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
972 (Current).first_line = (Current).last_line = \
973 YYRHSLOC (Rhs, 0).last_line; \
974 (Current).first_column = (Current).last_column = \
975 YYRHSLOC (Rhs, 0).last_column; \
981 /* YY_LOCATION_PRINT -- Print the location on the stream.
982 This macro was not mandated originally: define only if we know
983 we won't break user code: when these are the locations we know. */
985 #ifndef YY_LOCATION_PRINT
986 # if YYLTYPE_IS_TRIVIAL
987 # define YY_LOCATION_PRINT(File, Loc) \
988 fprintf (File, "%d.%d-%d.%d", \
989 (Loc).first_line, (Loc).first_column, \
990 (Loc).last_line, (Loc).last_column)
992 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
997 /* YYLEX -- calling `yylex' with the right arguments. */
1000 # define YYLEX yylex (&yylval, YYLEX_PARAM)
1002 # define YYLEX yylex (&yylval, pc)
1005 /* Enable debugging if requested. */
1009 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1010 # define YYFPRINTF fprintf
1013 # define YYDPRINTF(Args) \
1019 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1023 YYFPRINTF (stderr, "%s ", Title); \
1024 yy_symbol_print (stderr, \
1026 YYFPRINTF (stderr, "\n"); \
1031 /*--------------------------------.
1032 | Print this symbol on YYOUTPUT. |
1033 `--------------------------------*/
1036 #if (defined __STDC__ || defined __C99__FUNC__ \
1037 || defined __cplusplus || defined _MSC_VER)
1039 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_control *pc)
1042 yy_symbol_value_print (yyoutput, yytype, yyvaluep, pc)
1045 YYSTYPE const * const yyvaluep;
1053 if (yytype < YYNTOKENS)
1054 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1066 /*--------------------------------.
1067 | Print this symbol on YYOUTPUT. |
1068 `--------------------------------*/
1070 #if (defined __STDC__ || defined __C99__FUNC__ \
1071 || defined __cplusplus || defined _MSC_VER)
1073 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_control *pc)
1076 yy_symbol_print (yyoutput, yytype, yyvaluep, pc)
1079 YYSTYPE const * const yyvaluep;
1083 if (yytype < YYNTOKENS)
1084 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1086 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1088 yy_symbol_value_print (yyoutput, yytype, yyvaluep, pc);
1089 YYFPRINTF (yyoutput, ")");
1092 /*------------------------------------------------------------------.
1093 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1095 `------------------------------------------------------------------*/
1097 #if (defined __STDC__ || defined __C99__FUNC__ \
1098 || defined __cplusplus || defined _MSC_VER)
1100 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
1103 yy_stack_print (bottom, top)
1104 yytype_int16 *bottom;
1108 YYFPRINTF (stderr, "Stack now");
1109 for (; bottom <= top; ++bottom)
1110 YYFPRINTF (stderr, " %d", *bottom);
1111 YYFPRINTF (stderr, "\n");
1114 # define YY_STACK_PRINT(Bottom, Top) \
1117 yy_stack_print ((Bottom), (Top)); \
1121 /*------------------------------------------------.
1122 | Report that the YYRULE is going to be reduced. |
1123 `------------------------------------------------*/
1125 #if (defined __STDC__ || defined __C99__FUNC__ \
1126 || defined __cplusplus || defined _MSC_VER)
1128 yy_reduce_print (YYSTYPE *yyvsp, int yyrule, parser_control *pc)
1131 yy_reduce_print (yyvsp, yyrule, pc)
1137 int yynrhs = yyr2[yyrule];
1139 unsigned long int yylno = yyrline[yyrule];
1140 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1142 /* The symbols being reduced. */
1143 for (yyi = 0; yyi < yynrhs; yyi++)
1145 fprintf (stderr, " $%d = ", yyi + 1);
1146 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1147 &(yyvsp[(yyi + 1) - (yynrhs)])
1149 fprintf (stderr, "\n");
1153 # define YY_REDUCE_PRINT(Rule) \
1156 yy_reduce_print (yyvsp, Rule, pc); \
1159 /* Nonzero means print parse trace. It is left uninitialized so that
1160 multiple parsers can coexist. */
1162 #else /* !YYDEBUG */
1163 # define YYDPRINTF(Args)
1164 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1165 # define YY_STACK_PRINT(Bottom, Top)
1166 # define YY_REDUCE_PRINT(Rule)
1167 #endif /* !YYDEBUG */
1170 /* YYINITDEPTH -- initial size of the parser's stacks. */
1172 # define YYINITDEPTH 200
1175 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1176 if the built-in stack extension method is used).
1178 Do not make this value too large; the results are undefined if
1179 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1180 evaluated with infinite-precision integer arithmetic. */
1183 # define YYMAXDEPTH 10000
1191 # if defined __GLIBC__ && defined _STRING_H
1192 # define yystrlen strlen
1194 /* Return the length of YYSTR. */
1195 #if (defined __STDC__ || defined __C99__FUNC__ \
1196 || defined __cplusplus || defined _MSC_VER)
1198 yystrlen (const char *yystr)
1206 for (yylen = 0; yystr[yylen]; yylen++)
1214 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1215 # define yystpcpy stpcpy
1217 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1219 #if (defined __STDC__ || defined __C99__FUNC__ \
1220 || defined __cplusplus || defined _MSC_VER)
1222 yystpcpy (char *yydest, const char *yysrc)
1225 yystpcpy (yydest, yysrc)
1231 const char *yys = yysrc;
1233 while ((*yyd++ = *yys++) != '\0')
1242 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1243 quotes and backslashes, so that it's suitable for yyerror. The
1244 heuristic is that double-quoting is unnecessary unless the string
1245 contains an apostrophe, a comma, or backslash (other than
1246 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1247 null, do not copy; instead, return the length of what the result
1250 yytnamerr (char *yyres, const char *yystr)
1255 char const *yyp = yystr;
1262 goto do_not_strip_quotes;
1266 goto do_not_strip_quotes;
1279 do_not_strip_quotes: ;
1283 return yystrlen (yystr);
1285 return yystpcpy (yyres, yystr) - yyres;
1289 /* Copy into YYRESULT an error message about the unexpected token
1290 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1291 including the terminating null byte. If YYRESULT is null, do not
1292 copy anything; just return the number of bytes that would be
1293 copied. As a special case, return 0 if an ordinary "syntax error"
1294 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1295 size calculation. */
1297 yysyntax_error (char *yyresult, int yystate, int yychar)
1299 int yyn = yypact[yystate];
1301 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1305 int yytype = YYTRANSLATE (yychar);
1306 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1307 YYSIZE_T yysize = yysize0;
1309 int yysize_overflow = 0;
1310 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1311 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1315 /* This is so xgettext sees the translatable formats that are
1316 constructed on the fly. */
1317 YY_("syntax error, unexpected %s");
1318 YY_("syntax error, unexpected %s, expecting %s");
1319 YY_("syntax error, unexpected %s, expecting %s or %s");
1320 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1321 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1325 static char const yyunexpected[] = "syntax error, unexpected %s";
1326 static char const yyexpecting[] = ", expecting %s";
1327 static char const yyor[] = " or %s";
1328 char yyformat[sizeof yyunexpected
1329 + sizeof yyexpecting - 1
1330 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1331 * (sizeof yyor - 1))];
1332 char const *yyprefix = yyexpecting;
1334 /* Start YYX at -YYN if negative to avoid negative indexes in
1336 int yyxbegin = yyn < 0 ? -yyn : 0;
1338 /* Stay within bounds of both yycheck and yytname. */
1339 int yychecklim = YYLAST - yyn + 1;
1340 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1343 yyarg[0] = yytname[yytype];
1344 yyfmt = yystpcpy (yyformat, yyunexpected);
1346 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1347 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1349 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1353 yyformat[sizeof yyunexpected - 1] = '\0';
1356 yyarg[yycount++] = yytname[yyx];
1357 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1358 yysize_overflow |= (yysize1 < yysize);
1360 yyfmt = yystpcpy (yyfmt, yyprefix);
1364 yyf = YY_(yyformat);
1365 yysize1 = yysize + yystrlen (yyf);
1366 yysize_overflow |= (yysize1 < yysize);
1369 if (yysize_overflow)
1370 return YYSIZE_MAXIMUM;
1374 /* Avoid sprintf, as that infringes on the user's name space.
1375 Don't have undefined behavior even if the translation
1376 produced a string with the wrong number of "%s"s. */
1377 char *yyp = yyresult;
1379 while ((*yyp = *yyf) != '\0')
1381 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1383 yyp += yytnamerr (yyp, yyarg[yyi++]);
1396 #endif /* YYERROR_VERBOSE */
1399 /*-----------------------------------------------.
1400 | Release the memory associated to this symbol. |
1401 `-----------------------------------------------*/
1404 #if (defined __STDC__ || defined __C99__FUNC__ \
1405 || defined __cplusplus || defined _MSC_VER)
1407 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, parser_control *pc)
1410 yydestruct (yymsg, yytype, yyvaluep, pc)
1422 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1433 /* Prevent warnings from -Wmissing-prototypes. */
1435 #ifdef YYPARSE_PARAM
1436 #if defined __STDC__ || defined __cplusplus
1437 int yyparse (void *YYPARSE_PARAM);
1441 #else /* ! YYPARSE_PARAM */
1442 #if defined __STDC__ || defined __cplusplus
1443 int yyparse (parser_control *pc);
1447 #endif /* ! YYPARSE_PARAM */
1458 #ifdef YYPARSE_PARAM
1459 #if (defined __STDC__ || defined __C99__FUNC__ \
1460 || defined __cplusplus || defined _MSC_VER)
1462 yyparse (void *YYPARSE_PARAM)
1465 yyparse (YYPARSE_PARAM)
1466 void *YYPARSE_PARAM;
1468 #else /* ! YYPARSE_PARAM */
1469 #if (defined __STDC__ || defined __C99__FUNC__ \
1470 || defined __cplusplus || defined _MSC_VER)
1472 yyparse (parser_control *pc)
1480 /* The look-ahead symbol. */
1483 /* The semantic value of the look-ahead symbol. */
1486 /* Number of syntax errors so far. */
1492 /* Number of tokens to shift before error messages enabled. */
1494 /* Look-ahead token as an internal (translated) token number. */
1497 /* Buffer for error messages, and its allocated size. */
1499 char *yymsg = yymsgbuf;
1500 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1503 /* Three stacks and their tools:
1504 `yyss': related to states,
1505 `yyvs': related to semantic values,
1506 `yyls': related to locations.
1508 Refer to the stacks thru separate pointers, to allow yyoverflow
1509 to reallocate them elsewhere. */
1511 /* The state stack. */
1512 yytype_int16 yyssa[YYINITDEPTH];
1513 yytype_int16 *yyss = yyssa;
1514 yytype_int16 *yyssp;
1516 /* The semantic value stack. */
1517 YYSTYPE yyvsa[YYINITDEPTH];
1518 YYSTYPE *yyvs = yyvsa;
1523 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1525 YYSIZE_T yystacksize = YYINITDEPTH;
1527 /* The variables used to return semantic value and location from the
1532 /* The number of symbols on the RHS of the reduced rule.
1533 Keep to zero when no symbol should be popped. */
1536 YYDPRINTF ((stderr, "Starting parse\n"));
1541 yychar = YYEMPTY; /* Cause a token to be read. */
1543 /* Initialize stack pointers.
1544 Waste one element of value and location stack
1545 so that they stay on the same level as the state stack.
1546 The wasted elements are never initialized. */
1553 /*------------------------------------------------------------.
1554 | yynewstate -- Push a new state, which is found in yystate. |
1555 `------------------------------------------------------------*/
1557 /* In all cases, when you get here, the value and location stacks
1558 have just been pushed. So pushing a state here evens the stacks. */
1564 if (yyss + yystacksize - 1 <= yyssp)
1566 /* Get the current used size of the three stacks, in elements. */
1567 YYSIZE_T yysize = yyssp - yyss + 1;
1571 /* Give user a chance to reallocate the stack. Use copies of
1572 these so that the &'s don't force the real ones into
1574 YYSTYPE *yyvs1 = yyvs;
1575 yytype_int16 *yyss1 = yyss;
1578 /* Each stack pointer address is followed by the size of the
1579 data in use in that stack, in bytes. This used to be a
1580 conditional around just the two extra args, but that might
1581 be undefined if yyoverflow is a macro. */
1582 yyoverflow (YY_("memory exhausted"),
1583 &yyss1, yysize * sizeof (*yyssp),
1584 &yyvs1, yysize * sizeof (*yyvsp),
1591 #else /* no yyoverflow */
1592 # ifndef YYSTACK_RELOCATE
1593 goto yyexhaustedlab;
1595 /* Extend the stack our own way. */
1596 if (YYMAXDEPTH <= yystacksize)
1597 goto yyexhaustedlab;
1599 if (YYMAXDEPTH < yystacksize)
1600 yystacksize = YYMAXDEPTH;
1603 yytype_int16 *yyss1 = yyss;
1604 union yyalloc *yyptr =
1605 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1607 goto yyexhaustedlab;
1608 YYSTACK_RELOCATE (yyss);
1609 YYSTACK_RELOCATE (yyvs);
1611 # undef YYSTACK_RELOCATE
1613 YYSTACK_FREE (yyss1);
1616 #endif /* no yyoverflow */
1618 yyssp = yyss + yysize - 1;
1619 yyvsp = yyvs + yysize - 1;
1622 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1623 (unsigned long int) yystacksize));
1625 if (yyss + yystacksize - 1 <= yyssp)
1629 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1638 /* Do appropriate processing given the current state. Read a
1639 look-ahead token if we need one and don't already have one. */
1641 /* First try to decide what to do without reference to look-ahead token. */
1642 yyn = yypact[yystate];
1643 if (yyn == YYPACT_NINF)
1646 /* Not known => get a look-ahead token if don't already have one. */
1648 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1649 if (yychar == YYEMPTY)
1651 YYDPRINTF ((stderr, "Reading a token: "));
1655 if (yychar <= YYEOF)
1657 yychar = yytoken = YYEOF;
1658 YYDPRINTF ((stderr, "Now at end of input.\n"));
1662 yytoken = YYTRANSLATE (yychar);
1663 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1666 /* If the proper action on seeing token YYTOKEN is to reduce or to
1667 detect an error, take that action. */
1669 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1674 if (yyn == 0 || yyn == YYTABLE_NINF)
1683 /* Count tokens shifted since error; after three, turn off error
1688 /* Shift the look-ahead token. */
1689 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1691 /* Discard the shifted token unless it is eof. */
1692 if (yychar != YYEOF)
1701 /*-----------------------------------------------------------.
1702 | yydefault -- do the default action for the current state. |
1703 `-----------------------------------------------------------*/
1705 yyn = yydefact[yystate];
1711 /*-----------------------------.
1712 | yyreduce -- Do a reduction. |
1713 `-----------------------------*/
1715 /* yyn is the number of a rule to reduce with. */
1718 /* If YYLEN is nonzero, implement the default value of the action:
1721 Otherwise, the following line sets YYVAL to garbage.
1722 This behavior is undocumented and Bison
1723 users should not rely upon it. Assigning to YYVAL
1724 unconditionally makes the parser a bit smaller, and it avoids a
1725 GCC warning that YYVAL may be used uninitialized. */
1726 yyval = yyvsp[1-yylen];
1729 YY_REDUCE_PRINT (yyn);
1733 #line 318 "getdate.y"
1735 pc->seconds = (yyvsp[(2) - (2)].timespec);
1736 pc->timespec_seen = true;
1741 #line 331 "getdate.y"
1742 { pc->times_seen++; }
1746 #line 333 "getdate.y"
1747 { pc->local_zones_seen++; }
1751 #line 335 "getdate.y"
1752 { pc->zones_seen++; }
1756 #line 337 "getdate.y"
1757 { pc->dates_seen++; }
1761 #line 339 "getdate.y"
1762 { pc->days_seen++; }
1766 #line 347 "getdate.y"
1768 set_hhmmss (pc, (yyvsp[(1) - (2)].textintval).value, 0, 0, 0);
1769 pc->meridian = (yyvsp[(2) - (2)].intval);
1774 #line 352 "getdate.y"
1776 set_hhmmss (pc, (yyvsp[(1) - (4)].textintval).value, (yyvsp[(3) - (4)].textintval).value, 0, 0);
1777 pc->meridian = (yyvsp[(4) - (4)].intval);
1782 #line 357 "getdate.y"
1784 set_hhmmss (pc, (yyvsp[(1) - (5)].textintval).value, (yyvsp[(3) - (5)].textintval).value, 0, 0);
1785 pc->meridian = MER24;
1787 pc->time_zone = time_zone_hhmm (pc, (yyvsp[(4) - (5)].textintval), (yyvsp[(5) - (5)].intval));
1792 #line 364 "getdate.y"
1794 set_hhmmss (pc, (yyvsp[(1) - (6)].textintval).value, (yyvsp[(3) - (6)].textintval).value, (yyvsp[(5) - (6)].timespec).tv_sec, (yyvsp[(5) - (6)].timespec).tv_nsec);
1795 pc->meridian = (yyvsp[(6) - (6)].intval);
1800 #line 369 "getdate.y"
1802 set_hhmmss (pc, (yyvsp[(1) - (7)].textintval).value, (yyvsp[(3) - (7)].textintval).value, (yyvsp[(5) - (7)].timespec).tv_sec, (yyvsp[(5) - (7)].timespec).tv_nsec);
1803 pc->meridian = MER24;
1805 pc->time_zone = time_zone_hhmm (pc, (yyvsp[(6) - (7)].textintval), (yyvsp[(7) - (7)].intval));
1810 #line 379 "getdate.y"
1812 pc->local_isdst = (yyvsp[(1) - (1)].intval);
1813 pc->dsts_seen += (0 < (yyvsp[(1) - (1)].intval));
1818 #line 384 "getdate.y"
1820 pc->local_isdst = 1;
1821 pc->dsts_seen += (0 < (yyvsp[(1) - (2)].intval)) + 1;
1826 #line 392 "getdate.y"
1827 { pc->time_zone = (yyvsp[(1) - (1)].intval); }
1831 #line 394 "getdate.y"
1832 { pc->time_zone = (yyvsp[(1) - (2)].intval);
1833 apply_relative_time (pc, (yyvsp[(2) - (2)].rel), 1); }
1837 #line 397 "getdate.y"
1838 { pc->time_zone = (yyvsp[(1) - (3)].intval) + time_zone_hhmm (pc, (yyvsp[(2) - (3)].textintval), (yyvsp[(3) - (3)].intval)); }
1842 #line 399 "getdate.y"
1843 { pc->time_zone = (yyvsp[(1) - (1)].intval) + 60; }
1847 #line 401 "getdate.y"
1848 { pc->time_zone = (yyvsp[(1) - (2)].intval) + 60; }
1852 #line 406 "getdate.y"
1854 pc->day_ordinal = 1;
1855 pc->day_number = (yyvsp[(1) - (1)].intval);
1860 #line 411 "getdate.y"
1862 pc->day_ordinal = 1;
1863 pc->day_number = (yyvsp[(1) - (2)].intval);
1868 #line 416 "getdate.y"
1870 pc->day_ordinal = (yyvsp[(1) - (2)].intval);
1871 pc->day_number = (yyvsp[(2) - (2)].intval);
1876 #line 421 "getdate.y"
1878 pc->day_ordinal = (yyvsp[(1) - (2)].textintval).value;
1879 pc->day_number = (yyvsp[(2) - (2)].intval);
1884 #line 429 "getdate.y"
1886 pc->month = (yyvsp[(1) - (3)].textintval).value;
1887 pc->day = (yyvsp[(3) - (3)].textintval).value;
1892 #line 434 "getdate.y"
1894 /* Interpret as YYYY/MM/DD if the first value has 4 or more digits,
1895 otherwise as MM/DD/YY.
1896 The goal in recognizing YYYY/MM/DD is solely to support legacy
1897 machine-generated dates like those in an RCS log listing. If
1898 you want portability, use the ISO 8601 format. */
1899 if (4 <= (yyvsp[(1) - (5)].textintval).digits)
1901 pc->year = (yyvsp[(1) - (5)].textintval);
1902 pc->month = (yyvsp[(3) - (5)].textintval).value;
1903 pc->day = (yyvsp[(5) - (5)].textintval).value;
1907 pc->month = (yyvsp[(1) - (5)].textintval).value;
1908 pc->day = (yyvsp[(3) - (5)].textintval).value;
1909 pc->year = (yyvsp[(5) - (5)].textintval);
1915 #line 454 "getdate.y"
1917 /* ISO 8601 format. YYYY-MM-DD. */
1918 pc->year = (yyvsp[(1) - (3)].textintval);
1919 pc->month = -(yyvsp[(2) - (3)].textintval).value;
1920 pc->day = -(yyvsp[(3) - (3)].textintval).value;
1925 #line 461 "getdate.y"
1927 /* e.g. 17-JUN-1992. */
1928 pc->day = (yyvsp[(1) - (3)].textintval).value;
1929 pc->month = (yyvsp[(2) - (3)].intval);
1930 pc->year.value = -(yyvsp[(3) - (3)].textintval).value;
1931 pc->year.digits = (yyvsp[(3) - (3)].textintval).digits;
1936 #line 469 "getdate.y"
1938 /* e.g. JUN-17-1992. */
1939 pc->month = (yyvsp[(1) - (3)].intval);
1940 pc->day = -(yyvsp[(2) - (3)].textintval).value;
1941 pc->year.value = -(yyvsp[(3) - (3)].textintval).value;
1942 pc->year.digits = (yyvsp[(3) - (3)].textintval).digits;
1947 #line 477 "getdate.y"
1949 pc->month = (yyvsp[(1) - (2)].intval);
1950 pc->day = (yyvsp[(2) - (2)].textintval).value;
1955 #line 482 "getdate.y"
1957 pc->month = (yyvsp[(1) - (4)].intval);
1958 pc->day = (yyvsp[(2) - (4)].textintval).value;
1959 pc->year = (yyvsp[(4) - (4)].textintval);
1964 #line 488 "getdate.y"
1966 pc->day = (yyvsp[(1) - (2)].textintval).value;
1967 pc->month = (yyvsp[(2) - (2)].intval);
1972 #line 493 "getdate.y"
1974 pc->day = (yyvsp[(1) - (3)].textintval).value;
1975 pc->month = (yyvsp[(2) - (3)].intval);
1976 pc->year = (yyvsp[(3) - (3)].textintval);
1981 #line 502 "getdate.y"
1982 { apply_relative_time (pc, (yyvsp[(1) - (2)].rel), -1); }
1986 #line 504 "getdate.y"
1987 { apply_relative_time (pc, (yyvsp[(1) - (1)].rel), 1); }
1991 #line 506 "getdate.y"
1992 { apply_relative_time (pc, (yyvsp[(1) - (1)].rel), 1); }
1996 #line 511 "getdate.y"
1997 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].intval); }
2001 #line 513 "getdate.y"
2002 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].textintval).value; }
2006 #line 515 "getdate.y"
2007 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = 1; }
2011 #line 517 "getdate.y"
2012 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].intval); }
2016 #line 519 "getdate.y"
2017 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].textintval).value; }
2021 #line 521 "getdate.y"
2022 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = 1; }
2026 #line 523 "getdate.y"
2027 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].intval) * (yyvsp[(2) - (2)].intval); }
2031 #line 525 "getdate.y"
2032 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); }
2036 #line 527 "getdate.y"
2037 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (1)].intval); }
2041 #line 529 "getdate.y"
2042 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].intval); }
2046 #line 531 "getdate.y"
2047 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].textintval).value; }
2051 #line 533 "getdate.y"
2052 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = 1; }
2056 #line 535 "getdate.y"
2057 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].intval); }
2061 #line 537 "getdate.y"
2062 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].textintval).value; }
2066 #line 539 "getdate.y"
2067 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = 1; }
2071 #line 541 "getdate.y"
2072 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].intval); }
2076 #line 543 "getdate.y"
2077 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].textintval).value; }
2081 #line 545 "getdate.y"
2082 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].timespec).tv_sec; (yyval.rel).ns = (yyvsp[(1) - (2)].timespec).tv_nsec; }
2086 #line 547 "getdate.y"
2087 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].timespec).tv_sec; (yyval.rel).ns = (yyvsp[(1) - (2)].timespec).tv_nsec; }
2091 #line 549 "getdate.y"
2092 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = 1; }
2096 #line 555 "getdate.y"
2097 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].textintval).value; }
2101 #line 557 "getdate.y"
2102 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].textintval).value; }
2106 #line 559 "getdate.y"
2107 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); }
2111 #line 561 "getdate.y"
2112 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].textintval).value; }
2116 #line 563 "getdate.y"
2117 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].textintval).value; }
2121 #line 565 "getdate.y"
2122 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].textintval).value; }
2126 #line 570 "getdate.y"
2127 { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (1)].intval); }
2131 #line 578 "getdate.y"
2132 { (yyval.timespec).tv_sec = (yyvsp[(1) - (1)].textintval).value; (yyval.timespec).tv_nsec = 0; }
2136 #line 584 "getdate.y"
2137 { (yyval.timespec).tv_sec = (yyvsp[(1) - (1)].textintval).value; (yyval.timespec).tv_nsec = 0; }
2141 #line 589 "getdate.y"
2142 { digits_to_date_time (pc, (yyvsp[(1) - (1)].textintval)); }
2146 #line 594 "getdate.y"
2148 /* Hybrid all-digit and relative offset, so that we accept e.g.,
2149 "YYYYMMDD +N days" as well as "YYYYMMDD N days". */
2150 digits_to_date_time (pc, (yyvsp[(1) - (2)].textintval));
2151 apply_relative_time (pc, (yyvsp[(2) - (2)].rel), 1);
2156 #line 604 "getdate.y"
2157 { (yyval.intval) = -1; }
2161 #line 606 "getdate.y"
2162 { (yyval.intval) = (yyvsp[(2) - (2)].textintval).value; }
2166 #line 611 "getdate.y"
2167 { (yyval.intval) = MER24; }
2171 #line 613 "getdate.y"
2172 { (yyval.intval) = (yyvsp[(1) - (1)].intval); }
2176 /* Line 1267 of yacc.c. */
2177 #line 2178 "getdate.c"
2180 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2184 YY_STACK_PRINT (yyss, yyssp);
2189 /* Now `shift' the result of the reduction. Determine what state
2190 that goes to, based on the state we popped back to and the rule
2191 number reduced by. */
2195 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2196 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2197 yystate = yytable[yystate];
2199 yystate = yydefgoto[yyn - YYNTOKENS];
2204 /*------------------------------------.
2205 | yyerrlab -- here on detecting error |
2206 `------------------------------------*/
2208 /* If not already recovering from an error, report this error. */
2212 #if ! YYERROR_VERBOSE
2213 yyerror (pc, YY_("syntax error"));
2216 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2217 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2219 YYSIZE_T yyalloc = 2 * yysize;
2220 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2221 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2222 if (yymsg != yymsgbuf)
2223 YYSTACK_FREE (yymsg);
2224 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2226 yymsg_alloc = yyalloc;
2230 yymsg_alloc = sizeof yymsgbuf;
2234 if (0 < yysize && yysize <= yymsg_alloc)
2236 (void) yysyntax_error (yymsg, yystate, yychar);
2237 yyerror (pc, yymsg);
2241 yyerror (pc, YY_("syntax error"));
2243 goto yyexhaustedlab;
2251 if (yyerrstatus == 3)
2253 /* If just tried and failed to reuse look-ahead token after an
2254 error, discard it. */
2256 if (yychar <= YYEOF)
2258 /* Return failure if at end of input. */
2259 if (yychar == YYEOF)
2264 yydestruct ("Error: discarding",
2265 yytoken, &yylval, pc);
2270 /* Else will try to reuse look-ahead token after shifting the error
2275 /*---------------------------------------------------.
2276 | yyerrorlab -- error raised explicitly by YYERROR. |
2277 `---------------------------------------------------*/
2280 /* Pacify compilers like GCC when the user code never invokes
2281 YYERROR and the label yyerrorlab therefore never appears in user
2283 if (/*CONSTCOND*/ 0)
2286 /* Do not reclaim the symbols of the rule which action triggered
2290 YY_STACK_PRINT (yyss, yyssp);
2295 /*-------------------------------------------------------------.
2296 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2297 `-------------------------------------------------------------*/
2299 yyerrstatus = 3; /* Each real token shifted decrements this. */
2303 yyn = yypact[yystate];
2304 if (yyn != YYPACT_NINF)
2307 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2315 /* Pop the current state because it cannot handle the error token. */
2320 yydestruct ("Error: popping",
2321 yystos[yystate], yyvsp, pc);
2324 YY_STACK_PRINT (yyss, yyssp);
2333 /* Shift the error token. */
2334 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2340 /*-------------------------------------.
2341 | yyacceptlab -- YYACCEPT comes here. |
2342 `-------------------------------------*/
2347 /*-----------------------------------.
2348 | yyabortlab -- YYABORT comes here. |
2349 `-----------------------------------*/
2355 /*-------------------------------------------------.
2356 | yyexhaustedlab -- memory exhaustion comes here. |
2357 `-------------------------------------------------*/
2359 yyerror (pc, YY_("memory exhausted"));
2365 if (yychar != YYEOF && yychar != YYEMPTY)
2366 yydestruct ("Cleanup: discarding lookahead",
2367 yytoken, &yylval, pc);
2368 /* Do not reclaim the symbols of the rule which action triggered
2369 this YYABORT or YYACCEPT. */
2371 YY_STACK_PRINT (yyss, yyssp);
2372 while (yyssp != yyss)
2374 yydestruct ("Cleanup: popping",
2375 yystos[*yyssp], yyvsp, pc);
2380 YYSTACK_FREE (yyss);
2383 if (yymsg != yymsgbuf)
2384 YYSTACK_FREE (yymsg);
2386 /* Make sure YYID is used. */
2387 return YYID (yyresult);
2391 #line 616 "getdate.y"
2394 static table const meridian_table[] =
2396 { "AM", tMERIDIAN, MERam },
2397 { "A.M.", tMERIDIAN, MERam },
2398 { "PM", tMERIDIAN, MERpm },
2399 { "P.M.", tMERIDIAN, MERpm },
2403 static table const dst_table[] =
2408 static table const month_and_day_table[] =
2410 { "JANUARY", tMONTH, 1 },
2411 { "FEBRUARY", tMONTH, 2 },
2412 { "MARCH", tMONTH, 3 },
2413 { "APRIL", tMONTH, 4 },
2414 { "MAY", tMONTH, 5 },
2415 { "JUNE", tMONTH, 6 },
2416 { "JULY", tMONTH, 7 },
2417 { "AUGUST", tMONTH, 8 },
2418 { "SEPTEMBER",tMONTH, 9 },
2419 { "SEPT", tMONTH, 9 },
2420 { "OCTOBER", tMONTH, 10 },
2421 { "NOVEMBER", tMONTH, 11 },
2422 { "DECEMBER", tMONTH, 12 },
2423 { "SUNDAY", tDAY, 0 },
2424 { "MONDAY", tDAY, 1 },
2425 { "TUESDAY", tDAY, 2 },
2426 { "TUES", tDAY, 2 },
2427 { "WEDNESDAY",tDAY, 3 },
2428 { "WEDNES", tDAY, 3 },
2429 { "THURSDAY", tDAY, 4 },
2430 { "THUR", tDAY, 4 },
2431 { "THURS", tDAY, 4 },
2432 { "FRIDAY", tDAY, 5 },
2433 { "SATURDAY", tDAY, 6 },
2437 static table const time_units_table[] =
2439 { "YEAR", tYEAR_UNIT, 1 },
2440 { "MONTH", tMONTH_UNIT, 1 },
2441 { "FORTNIGHT",tDAY_UNIT, 14 },
2442 { "WEEK", tDAY_UNIT, 7 },
2443 { "DAY", tDAY_UNIT, 1 },
2444 { "HOUR", tHOUR_UNIT, 1 },
2445 { "MINUTE", tMINUTE_UNIT, 1 },
2446 { "MIN", tMINUTE_UNIT, 1 },
2447 { "SECOND", tSEC_UNIT, 1 },
2448 { "SEC", tSEC_UNIT, 1 },
2452 /* Assorted relative-time words. */
2453 static table const relative_time_table[] =
2455 { "TOMORROW", tDAY_SHIFT, 1 },
2456 { "YESTERDAY",tDAY_SHIFT, -1 },
2457 { "TODAY", tDAY_SHIFT, 0 },
2458 { "NOW", tDAY_SHIFT, 0 },
2459 { "LAST", tORDINAL, -1 },
2460 { "THIS", tORDINAL, 0 },
2461 { "NEXT", tORDINAL, 1 },
2462 { "FIRST", tORDINAL, 1 },
2463 /*{ "SECOND", tORDINAL, 2 }, */
2464 { "THIRD", tORDINAL, 3 },
2465 { "FOURTH", tORDINAL, 4 },
2466 { "FIFTH", tORDINAL, 5 },
2467 { "SIXTH", tORDINAL, 6 },
2468 { "SEVENTH", tORDINAL, 7 },
2469 { "EIGHTH", tORDINAL, 8 },
2470 { "NINTH", tORDINAL, 9 },
2471 { "TENTH", tORDINAL, 10 },
2472 { "ELEVENTH", tORDINAL, 11 },
2473 { "TWELFTH", tORDINAL, 12 },
2478 /* The universal time zone table. These labels can be used even for
2479 time stamps that would not otherwise be valid, e.g., GMT time
2480 stamps in London during summer. */
2481 static table const universal_time_zone_table[] =
2483 { "GMT", tZONE, HOUR ( 0) }, /* Greenwich Mean */
2484 { "UT", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */
2485 { "UTC", tZONE, HOUR ( 0) },
2489 /* The time zone table. This table is necessarily incomplete, as time
2490 zone abbreviations are ambiguous; e.g. Australians interpret "EST"
2491 as Eastern time in Australia, not as US Eastern Standard Time.
2492 You cannot rely on getdate to handle arbitrary time zone
2493 abbreviations; use numeric abbreviations like `-0500' instead. */
2494 static table const time_zone_table[] =
2496 { "WET", tZONE, HOUR ( 0) }, /* Western European */
2497 { "WEST", tDAYZONE, HOUR ( 0) }, /* Western European Summer */
2498 { "BST", tDAYZONE, HOUR ( 0) }, /* British Summer */
2499 { "ART", tZONE, -HOUR ( 3) }, /* Argentina */
2500 { "BRT", tZONE, -HOUR ( 3) }, /* Brazil */
2501 { "BRST", tDAYZONE, -HOUR ( 3) }, /* Brazil Summer */
2502 { "NST", tZONE, -(HOUR ( 3) + 30) }, /* Newfoundland Standard */
2503 { "NDT", tDAYZONE,-(HOUR ( 3) + 30) }, /* Newfoundland Daylight */
2504 { "AST", tZONE, -HOUR ( 4) }, /* Atlantic Standard */
2505 { "ADT", tDAYZONE, -HOUR ( 4) }, /* Atlantic Daylight */
2506 { "CLT", tZONE, -HOUR ( 4) }, /* Chile */
2507 { "CLST", tDAYZONE, -HOUR ( 4) }, /* Chile Summer */
2508 { "EST", tZONE, -HOUR ( 5) }, /* Eastern Standard */
2509 { "EDT", tDAYZONE, -HOUR ( 5) }, /* Eastern Daylight */
2510 { "CST", tZONE, -HOUR ( 6) }, /* Central Standard */
2511 { "CDT", tDAYZONE, -HOUR ( 6) }, /* Central Daylight */
2512 { "MST", tZONE, -HOUR ( 7) }, /* Mountain Standard */
2513 { "MDT", tDAYZONE, -HOUR ( 7) }, /* Mountain Daylight */
2514 { "PST", tZONE, -HOUR ( 8) }, /* Pacific Standard */
2515 { "PDT", tDAYZONE, -HOUR ( 8) }, /* Pacific Daylight */
2516 { "AKST", tZONE, -HOUR ( 9) }, /* Alaska Standard */
2517 { "AKDT", tDAYZONE, -HOUR ( 9) }, /* Alaska Daylight */
2518 { "HST", tZONE, -HOUR (10) }, /* Hawaii Standard */
2519 { "HAST", tZONE, -HOUR (10) }, /* Hawaii-Aleutian Standard */
2520 { "HADT", tDAYZONE, -HOUR (10) }, /* Hawaii-Aleutian Daylight */
2521 { "SST", tZONE, -HOUR (12) }, /* Samoa Standard */
2522 { "WAT", tZONE, HOUR ( 1) }, /* West Africa */
2523 { "CET", tZONE, HOUR ( 1) }, /* Central European */
2524 { "CEST", tDAYZONE, HOUR ( 1) }, /* Central European Summer */
2525 { "MET", tZONE, HOUR ( 1) }, /* Middle European */
2526 { "MEZ", tZONE, HOUR ( 1) }, /* Middle European */
2527 { "MEST", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */
2528 { "MESZ", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */
2529 { "EET", tZONE, HOUR ( 2) }, /* Eastern European */
2530 { "EEST", tDAYZONE, HOUR ( 2) }, /* Eastern European Summer */
2531 { "CAT", tZONE, HOUR ( 2) }, /* Central Africa */
2532 { "SAST", tZONE, HOUR ( 2) }, /* South Africa Standard */
2533 { "EAT", tZONE, HOUR ( 3) }, /* East Africa */
2534 { "MSK", tZONE, HOUR ( 3) }, /* Moscow */
2535 { "MSD", tDAYZONE, HOUR ( 3) }, /* Moscow Daylight */
2536 { "IST", tZONE, (HOUR ( 5) + 30) }, /* India Standard */
2537 { "SGT", tZONE, HOUR ( 8) }, /* Singapore */
2538 { "KST", tZONE, HOUR ( 9) }, /* Korea Standard */
2539 { "JST", tZONE, HOUR ( 9) }, /* Japan Standard */
2540 { "GST", tZONE, HOUR (10) }, /* Guam Standard */
2541 { "NZST", tZONE, HOUR (12) }, /* New Zealand Standard */
2542 { "NZDT", tDAYZONE, HOUR (12) }, /* New Zealand Daylight */
2546 /* Military time zone table. */
2547 static table const military_table[] =
2549 { "A", tZONE, -HOUR ( 1) },
2550 { "B", tZONE, -HOUR ( 2) },
2551 { "C", tZONE, -HOUR ( 3) },
2552 { "D", tZONE, -HOUR ( 4) },
2553 { "E", tZONE, -HOUR ( 5) },
2554 { "F", tZONE, -HOUR ( 6) },
2555 { "G", tZONE, -HOUR ( 7) },
2556 { "H", tZONE, -HOUR ( 8) },
2557 { "I", tZONE, -HOUR ( 9) },
2558 { "K", tZONE, -HOUR (10) },
2559 { "L", tZONE, -HOUR (11) },
2560 { "M", tZONE, -HOUR (12) },
2561 { "N", tZONE, HOUR ( 1) },
2562 { "O", tZONE, HOUR ( 2) },
2563 { "P", tZONE, HOUR ( 3) },
2564 { "Q", tZONE, HOUR ( 4) },
2565 { "R", tZONE, HOUR ( 5) },
2566 { "S", tZONE, HOUR ( 6) },
2567 { "T", tZONE, HOUR ( 7) },
2568 { "U", tZONE, HOUR ( 8) },
2569 { "V", tZONE, HOUR ( 9) },
2570 { "W", tZONE, HOUR (10) },
2571 { "X", tZONE, HOUR (11) },
2572 { "Y", tZONE, HOUR (12) },
2573 { "Z", tZONE, HOUR ( 0) },
2579 /* Convert a time zone expressed as HH:MM into an integer count of
2580 minutes. If MM is negative, then S is of the form HHMM and needs
2581 to be picked apart; otherwise, S is of the form HH. As specified in
2582 http://www.opengroup.org/susv3xbd/xbd_chap08.html#tag_08_03, allow
2583 only valid TZ range, and consider first two digits as hours, if no
2584 minutes specified. */
2587 time_zone_hhmm (parser_control *pc, textint s, long int mm)
2591 /* If the length of S is 1 or 2 and no minutes are specified,
2592 interpret it as a number of hours. */
2593 if (s.digits <= 2 && mm < 0)
2597 n_minutes = (s.value / 100) * 60 + s.value % 100;
2599 n_minutes = s.value * 60 + (s.negative ? -mm : mm);
2601 /* If the absolute number of minutes is larger than 24 hours,
2602 arrange to reject it by incrementing pc->zones_seen. Thus,
2603 we allow only values in the range UTC-24:00 to UTC+24:00. */
2604 if (24 * 60 < abs (n_minutes))
2611 to_hour (long int hours, int meridian)
2615 default: /* Pacify GCC. */
2617 return 0 <= hours && hours < 24 ? hours : -1;
2619 return 0 < hours && hours < 12 ? hours : hours == 12 ? 0 : -1;
2621 return 0 < hours && hours < 12 ? hours + 12 : hours == 12 ? 12 : -1;
2626 to_year (textint textyear)
2628 long int year = textyear.value;
2633 /* XPG4 suggests that years 00-68 map to 2000-2068, and
2634 years 69-99 map to 1969-1999. */
2635 else if (textyear.digits == 2)
2636 year += year < 69 ? 2000 : 1900;
2641 static table const *
2642 lookup_zone (parser_control const *pc, char const *name)
2646 for (tp = universal_time_zone_table; tp->name; tp++)
2647 if (strcmp (name, tp->name) == 0)
2650 /* Try local zone abbreviations before those in time_zone_table, as
2651 the local ones are more likely to be right. */
2652 for (tp = pc->local_time_zone_table; tp->name; tp++)
2653 if (strcmp (name, tp->name) == 0)
2656 for (tp = time_zone_table; tp->name; tp++)
2657 if (strcmp (name, tp->name) == 0)
2663 #if ! HAVE_TM_GMTOFF
2664 /* Yield the difference between *A and *B,
2665 measured in seconds, ignoring leap seconds.
2666 The body of this function is taken directly from the GNU C Library;
2667 see src/strftime.c. */
2669 tm_diff (struct tm const *a, struct tm const *b)
2671 /* Compute intervening leap days correctly even if year is negative.
2672 Take care to avoid int overflow in leap day calculations. */
2673 int a4 = SHR (a->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (a->tm_year & 3);
2674 int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3);
2675 int a100 = a4 / 25 - (a4 % 25 < 0);
2676 int b100 = b4 / 25 - (b4 % 25 < 0);
2677 int a400 = SHR (a100, 2);
2678 int b400 = SHR (b100, 2);
2679 int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
2680 long int ayear = a->tm_year;
2681 long int years = ayear - b->tm_year;
2682 long int days = (365 * years + intervening_leap_days
2683 + (a->tm_yday - b->tm_yday));
2684 return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
2685 + (a->tm_min - b->tm_min))
2686 + (a->tm_sec - b->tm_sec));
2688 #endif /* ! HAVE_TM_GMTOFF */
2690 static table const *
2691 lookup_word (parser_control const *pc, char *word)
2700 /* Make it uppercase. */
2701 for (p = word; *p; p++)
2703 unsigned char ch = *p;
2704 *p = c_toupper (ch);
2707 for (tp = meridian_table; tp->name; tp++)
2708 if (strcmp (word, tp->name) == 0)
2711 /* See if we have an abbreviation for a month. */
2712 wordlen = strlen (word);
2713 abbrev = wordlen == 3 || (wordlen == 4 && word[3] == '.');
2715 for (tp = month_and_day_table; tp->name; tp++)
2716 if ((abbrev ? strncmp (word, tp->name, 3) : strcmp (word, tp->name)) == 0)
2719 if ((tp = lookup_zone (pc, word)))
2722 if (strcmp (word, dst_table[0].name) == 0)
2725 for (tp = time_units_table; tp->name; tp++)
2726 if (strcmp (word, tp->name) == 0)
2729 /* Strip off any plural and try the units table again. */
2730 if (word[wordlen - 1] == 'S')
2732 word[wordlen - 1] = '\0';
2733 for (tp = time_units_table; tp->name; tp++)
2734 if (strcmp (word, tp->name) == 0)
2736 word[wordlen - 1] = 'S'; /* For "this" in relative_time_table. */
2739 for (tp = relative_time_table; tp->name; tp++)
2740 if (strcmp (word, tp->name) == 0)
2743 /* Military time zones. */
2745 for (tp = military_table; tp->name; tp++)
2746 if (word[0] == tp->name[0])
2749 /* Drop out any periods and try the time zone table again. */
2750 for (period_found = false, p = q = word; (*p = *q); q++)
2752 period_found = true;
2755 if (period_found && (tp = lookup_zone (pc, word)))
2762 yylex (YYSTYPE *lvalp, parser_control *pc)
2769 while (c = *pc->input, c_isspace (c))
2772 if (ISDIGIT (c) || c == '-' || c == '+')
2776 unsigned long int value;
2777 if (c == '-' || c == '+')
2779 sign = c == '-' ? -1 : 1;
2780 while (c = *++pc->input, c_isspace (c))
2783 /* skip the '-' sign */
2789 for (value = 0; ; value *= 10)
2791 unsigned long int value1 = value + (c - '0');
2798 if (ULONG_MAX / 10 < value)
2801 if ((c == '.' || c == ',') && ISDIGIT (p[1]))
2806 unsigned long int value1;
2808 /* Check for overflow when converting value to time_t. */
2823 if (value != value1)
2826 /* Accumulate fraction, to ns precision. */
2829 for (digits = 2; digits <= LOG10_BILLION; digits++)
2836 /* Skip excess digits, truncating toward -Infinity. */
2838 for (; ISDIGIT (*p); p++)
2844 while (ISDIGIT (*p))
2847 /* Adjust to the timespec convention, which is that
2848 tv_nsec is always a positive offset even if tv_sec is
2858 lvalp->timespec.tv_sec = s;
2859 lvalp->timespec.tv_nsec = ns;
2861 return sign ? tSDECIMAL_NUMBER : tUDECIMAL_NUMBER;
2865 lvalp->textintval.negative = sign < 0;
2868 lvalp->textintval.value = - value;
2869 if (0 < lvalp->textintval.value)
2874 lvalp->textintval.value = value;
2875 if (lvalp->textintval.value < 0)
2878 lvalp->textintval.digits = p - pc->input;
2880 return sign ? tSNUMBER : tUNUMBER;
2892 if (p < buff + sizeof buff - 1)
2896 while (c_isalpha (c) || c == '.');
2899 tp = lookup_word (pc, buff);
2902 lvalp->intval = tp->value;
2907 return *pc->input++;
2923 /* Do nothing if the parser reports an error. */
2925 yyerror (parser_control const *pc ATTRIBUTE_UNUSED,
2926 char const *s ATTRIBUTE_UNUSED)
2931 /* If *TM0 is the old and *TM1 is the new value of a struct tm after
2932 passing it to mktime, return true if it's OK that mktime returned T.
2933 It's not OK if *TM0 has out-of-range members. */
2936 mktime_ok (struct tm const *tm0, struct tm const *tm1, time_t t)
2938 if (t == (time_t) -1)
2940 /* Guard against falsely reporting an error when parsing a time
2941 stamp that happens to equal (time_t) -1, on a host that
2942 supports such a time stamp. */
2943 tm1 = localtime (&t);
2948 return ! ((tm0->tm_sec ^ tm1->tm_sec)
2949 | (tm0->tm_min ^ tm1->tm_min)
2950 | (tm0->tm_hour ^ tm1->tm_hour)
2951 | (tm0->tm_mday ^ tm1->tm_mday)
2952 | (tm0->tm_mon ^ tm1->tm_mon)
2953 | (tm0->tm_year ^ tm1->tm_year));
2956 /* A reasonable upper bound for the size of ordinary TZ strings.
2957 Use heap allocation if TZ's length exceeds this. */
2958 enum { TZBUFSIZE = 100 };
2960 /* Return a copy of TZ, stored in TZBUF if it fits, and heap-allocated
2963 get_tz (char tzbuf[TZBUFSIZE])
2965 char *tz = getenv ("TZ");
2968 size_t tzsize = strlen (tz) + 1;
2969 tz = (tzsize <= TZBUFSIZE
2970 ? memcpy (tzbuf, tz, tzsize)
2971 : xmemdup (tz, tzsize));
2976 /* Parse a date/time string, storing the resulting time value into *RESULT.
2977 The string itself is pointed to by P. Return true if successful.
2978 P can be an incomplete or relative time specification; if so, use
2979 *NOW as the basis for the returned time. */
2981 get_date (struct timespec *result, char const *p, struct timespec const *now)
2985 struct tm const *tmp;
2989 struct timespec gettime_buffer;
2991 bool tz_was_altered = false;
2993 char tz0buf[TZBUFSIZE];
2998 gettime (&gettime_buffer);
2999 now = &gettime_buffer;
3002 Start = now->tv_sec;
3003 Start_ns = now->tv_nsec;
3005 tmp = localtime (&now->tv_sec);
3009 while (c = *p, c_isspace (c))
3012 if (strncmp (p, "TZ=\"", 4) == 0)
3014 char const *tzbase = p + 4;
3018 for (s = tzbase; *s; s++, tzsize++)
3022 if (! (*s == '\\' || *s == '"'))
3029 char tz1buf[TZBUFSIZE];
3030 bool large_tz = TZBUFSIZE < tzsize;
3032 tz0 = get_tz (tz0buf);
3033 z = tz1 = large_tz ? xmalloc (tzsize) : tz1buf;
3034 for (s = tzbase; *s != '"'; s++)
3035 *z++ = *(s += *s == '\\');
3037 setenv_ok = setenv ("TZ", tz1, 1) == 0;
3042 tz_was_altered = true;
3047 /* As documented, be careful to treat the empty string just like
3048 a date string of "0". Without this, an empty string would be
3049 declared invalid when parsed during a DST transition. */
3054 pc.year.value = tmp->tm_year;
3055 pc.year.value += TM_YEAR_BASE;
3057 pc.month = tmp->tm_mon + 1;
3058 pc.day = tmp->tm_mday;
3059 pc.hour = tmp->tm_hour;
3060 pc.minutes = tmp->tm_min;
3061 pc.seconds.tv_sec = tmp->tm_sec;
3062 pc.seconds.tv_nsec = Start_ns;
3063 tm.tm_isdst = tmp->tm_isdst;
3065 pc.meridian = MER24;
3066 pc.rel = RELATIVE_TIME_0;
3067 pc.timespec_seen = false;
3068 pc.rels_seen = false;
3072 pc.local_zones_seen = 0;
3076 #if HAVE_STRUCT_TM_TM_ZONE
3077 pc.local_time_zone_table[0].name = tmp->tm_zone;
3078 pc.local_time_zone_table[0].type = tLOCAL_ZONE;
3079 pc.local_time_zone_table[0].value = tmp->tm_isdst;
3080 pc.local_time_zone_table[1].name = NULL;
3082 /* Probe the names used in the next three calendar quarters, looking
3083 for a tm_isdst different from the one we already have. */
3086 for (quarter = 1; quarter <= 3; quarter++)
3088 time_t probe = Start + quarter * (90 * 24 * 60 * 60);
3089 struct tm const *probe_tm = localtime (&probe);
3090 if (probe_tm && probe_tm->tm_zone
3091 && probe_tm->tm_isdst != pc.local_time_zone_table[0].value)
3094 pc.local_time_zone_table[1].name = probe_tm->tm_zone;
3095 pc.local_time_zone_table[1].type = tLOCAL_ZONE;
3096 pc.local_time_zone_table[1].value = probe_tm->tm_isdst;
3097 pc.local_time_zone_table[2].name = NULL;
3106 # if !HAVE_DECL_TZNAME
3107 extern char *tzname[];
3110 for (i = 0; i < 2; i++)
3112 pc.local_time_zone_table[i].name = tzname[i];
3113 pc.local_time_zone_table[i].type = tLOCAL_ZONE;
3114 pc.local_time_zone_table[i].value = i;
3116 pc.local_time_zone_table[i].name = NULL;
3119 pc.local_time_zone_table[0].name = NULL;
3123 if (pc.local_time_zone_table[0].name && pc.local_time_zone_table[1].name
3124 && ! strcmp (pc.local_time_zone_table[0].name,
3125 pc.local_time_zone_table[1].name))
3127 /* This locale uses the same abbrevation for standard and
3128 daylight times. So if we see that abbreviation, we don't
3129 know whether it's daylight time. */
3130 pc.local_time_zone_table[0].value = -1;
3131 pc.local_time_zone_table[1].name = NULL;
3134 if (yyparse (&pc) != 0)
3137 if (pc.timespec_seen)
3138 *result = pc.seconds;
3141 if (1 < (pc.times_seen | pc.dates_seen | pc.days_seen | pc.dsts_seen
3142 | (pc.local_zones_seen + pc.zones_seen)))
3145 tm.tm_year = to_year (pc.year) - TM_YEAR_BASE;
3146 tm.tm_mon = pc.month - 1;
3147 tm.tm_mday = pc.day;
3148 if (pc.times_seen || (pc.rels_seen && ! pc.dates_seen && ! pc.days_seen))
3150 tm.tm_hour = to_hour (pc.hour, pc.meridian);
3153 tm.tm_min = pc.minutes;
3154 tm.tm_sec = pc.seconds.tv_sec;
3158 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
3159 pc.seconds.tv_nsec = 0;
3162 /* Let mktime deduce tm_isdst if we have an absolute time stamp. */
3163 if (pc.dates_seen | pc.days_seen | pc.times_seen)
3166 /* But if the input explicitly specifies local time with or without
3167 DST, give mktime that information. */
3168 if (pc.local_zones_seen)
3169 tm.tm_isdst = pc.local_isdst;
3173 Start = mktime (&tm);
3175 if (! mktime_ok (&tm0, &tm, Start))
3177 if (! pc.zones_seen)
3181 /* Guard against falsely reporting errors near the time_t
3182 boundaries when parsing times in other time zones. For
3183 example, suppose the input string "1969-12-31 23:00:00 -0100",
3184 the current time zone is 8 hours ahead of UTC, and the min
3185 time_t value is 1970-01-01 00:00:00 UTC. Then the min
3186 localtime value is 1970-01-01 08:00:00, and mktime will
3187 therefore fail on 1969-12-31 23:00:00. To work around the
3188 problem, set the time zone to 1 hour behind UTC temporarily
3189 by setting TZ="XXX1:00" and try mktime again. */
3191 long int time_zone = pc.time_zone;
3192 long int abs_time_zone = time_zone < 0 ? - time_zone : time_zone;
3193 long int abs_time_zone_hour = abs_time_zone / 60;
3194 int abs_time_zone_min = abs_time_zone % 60;
3195 char tz1buf[sizeof "XXX+0:00"
3196 + sizeof pc.time_zone * CHAR_BIT / 3];
3197 if (!tz_was_altered)
3198 tz0 = get_tz (tz0buf);
3199 sprintf (tz1buf, "XXX%s%ld:%02d", "-" + (time_zone < 0),
3200 abs_time_zone_hour, abs_time_zone_min);
3201 if (setenv ("TZ", tz1buf, 1) != 0)
3203 tz_was_altered = true;
3205 Start = mktime (&tm);
3206 if (! mktime_ok (&tm0, &tm, Start))
3211 if (pc.days_seen && ! pc.dates_seen)
3213 tm.tm_mday += ((pc.day_number - tm.tm_wday + 7) % 7
3214 + 7 * (pc.day_ordinal - (0 < pc.day_ordinal)));
3216 Start = mktime (&tm);
3217 if (Start == (time_t) -1)
3221 /* Add relative date. */
3222 if (pc.rel.year | pc.rel.month | pc.rel.day)
3224 int year = tm.tm_year + pc.rel.year;
3225 int month = tm.tm_mon + pc.rel.month;
3226 int day = tm.tm_mday + pc.rel.day;
3227 if (((year < tm.tm_year) ^ (pc.rel.year < 0))
3228 | ((month < tm.tm_mon) ^ (pc.rel.month < 0))
3229 | ((day < tm.tm_mday) ^ (pc.rel.day < 0)))
3234 tm.tm_hour = tm0.tm_hour;
3235 tm.tm_min = tm0.tm_min;
3236 tm.tm_sec = tm0.tm_sec;
3237 tm.tm_isdst = tm0.tm_isdst;
3238 Start = mktime (&tm);
3239 if (Start == (time_t) -1)
3243 /* The only "output" of this if-block is an updated Start value,
3244 so this block must follow others that clobber Start. */
3247 long int delta = pc.time_zone * 60;
3249 #ifdef HAVE_TM_GMTOFF
3250 delta -= tm.tm_gmtoff;
3253 struct tm const *gmt = gmtime (&t);
3256 delta -= tm_diff (&tm, gmt);
3259 if ((Start < t1) != (delta < 0))
3260 goto fail; /* time_t overflow */
3264 /* Add relative hours, minutes, and seconds. On hosts that support
3265 leap seconds, ignore the possibility of leap seconds; e.g.,
3266 "+ 10 minutes" adds 600 seconds, even if one of them is a
3267 leap second. Typically this is not what the user wants, but it's
3268 too hard to do it the other way, because the time zone indicator
3269 must be applied before relative times, and if mktime is applied
3270 again the time zone will be lost. */
3272 long int sum_ns = pc.seconds.tv_nsec + pc.rel.ns;
3273 long int normalized_ns = (sum_ns % BILLION + BILLION) % BILLION;
3275 long int d1 = 60 * 60 * pc.rel.hour;
3276 time_t t1 = t0 + d1;
3277 long int d2 = 60 * pc.rel.minutes;
3278 time_t t2 = t1 + d2;
3279 long int d3 = pc.rel.seconds;
3280 time_t t3 = t2 + d3;
3281 long int d4 = (sum_ns - normalized_ns) / BILLION;
3282 time_t t4 = t3 + d4;
3284 if ((d1 / (60 * 60) ^ pc.rel.hour)
3285 | (d2 / 60 ^ pc.rel.minutes)
3286 | ((t1 < t0) ^ (d1 < 0))
3287 | ((t2 < t1) ^ (d2 < 0))
3288 | ((t3 < t2) ^ (d3 < 0))
3289 | ((t4 < t3) ^ (d4 < 0)))
3292 result->tv_sec = t4;
3293 result->tv_nsec = normalized_ns;
3303 ok &= (tz0 ? setenv ("TZ", tz0, 1) : unsetenv ("TZ")) == 0;
3312 main (int ac, char **av)
3316 printf ("Enter date, or blank line to exit.\n\t> ");
3319 buff[BUFSIZ - 1] = '\0';
3320 while (fgets (buff, BUFSIZ - 1, stdin) && buff[0])
3323 struct tm const *tm;
3324 if (! get_date (&d, buff, NULL))
3325 printf ("Bad format - couldn't convert.\n");
3326 else if (! (tm = localtime (&d.tv_sec)))
3328 long int sec = d.tv_sec;
3329 printf ("localtime (%ld) failed\n", sec);
3334 printf ("%04ld-%02d-%02d %02d:%02d:%02d.%09d\n",
3335 tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
3336 tm->tm_hour, tm->tm_min, tm->tm_sec, ns);