Back to index

citadel  8.12
Classes | Defines | Typedefs | Enumerations | Functions | Variables
parsedate.c File Reference
#include "sysdep.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <ctype.h>
#include <time.h>
#include "parsedate.h"

Go to the source code of this file.

Classes

struct  _TABLE
union  YYSTYPE
union  yyalloc

Defines

#define YYBISON   1
#define YYBISON_VERSION   "2.5"
#define YYSKELETON_NAME   "yacc.c"
#define YYPURE   0
#define YYPUSH   0
#define YYPULL   1
#define YYLSP_NEEDED   0
#define yyparse   date_parse
#define yylex   date_lex
#define yyerror   date_error
#define EPOCH   1970
#define END_OF_TIME   2038
#define DST_OFFSET   1
#define SECSPERDAY   (24L * 60L * 60L)
#define HOUR(x)   (x * 60)
#define LPAREN   '('
#define RPAREN   ')'
#define IS7BIT(x)   ((unsigned int)(x) < 0200)
#define SIZEOF(array)   ((int)(sizeof array / sizeof array[0]))
#define ENDOF(array)   (&array[SIZEOF(array)])
#define YYDEBUG   0
#define YYERROR_VERBOSE   0
#define YYTOKEN_TABLE   0
#define YYTOKENTYPE
#define tDAY   258
#define tDAYZONE   259
#define tMERIDIAN   260
#define tMONTH   261
#define tMONTH_UNIT   262
#define tSEC_UNIT   263
#define tSNUMBER   264
#define tUNUMBER   265
#define tZONE   266
#define YYSTYPE_IS_TRIVIAL   1
#define yystype   YYSTYPE /* obsolescent; will be withdrawn */
#define YYSTYPE_IS_DECLARED   1
#define YYSIZE_T   unsigned int
#define YYSIZE_MAXIMUM   ((YYSIZE_T) -1)
#define YY_(msgid)   msgid
#define YYUSE(e)   ((void) (e))
#define YYID(n)   (n)
#define YYSTACK_ALLOC   YYMALLOC
#define YYSTACK_FREE   YYFREE
#define YYSTACK_ALLOC_MAXIMUM   YYSIZE_MAXIMUM
#define YYMALLOC   malloc
#define YYFREE   free
#define YYSTACK_GAP_MAXIMUM   (sizeof (union yyalloc) - 1)
#define YYSTACK_BYTES(N)
#define YYCOPY_NEEDED   1
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
#define YYCOPY(To, From, Count)
#define YYFINAL   2
#define YYLAST   40
#define YYNTOKENS   15
#define YYNNTS   9
#define YYNRULES   30
#define YYNSTATES   44
#define YYUNDEFTOK   2
#define YYMAXUTOK   266
#define YYTRANSLATE(YYX)   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
#define YYPACT_NINF   -29
#define YYTABLE_NINF   -1
#define yypact_value_is_default(yystate)   ((yystate) == (-29))
#define yytable_value_is_error(yytable_value)   YYID (0)
#define yyerrok   (yyerrstatus = 0)
#define yyclearin   (yychar = YYEMPTY)
#define YYEMPTY   (-2)
#define YYEOF   0
#define YYACCEPT   goto yyacceptlab
#define YYABORT   goto yyabortlab
#define YYERROR   goto yyerrorlab
#define YYFAIL   goto yyerrlab
#define YYRECOVERING()   (!!yyerrstatus)
#define YYBACKUP(Token, Value)
#define YYTERROR   1
#define YYERRCODE   256
#define YYRHSLOC(Rhs, K)   ((Rhs)[K])
#define YYLLOC_DEFAULT(Current, Rhs, N)
#define YY_LOCATION_PRINT(File, Loc)   ((void) 0)
#define YYLEX   yylex ()
#define YYDPRINTF(Args)
#define YY_SYMBOL_PRINT(Title, Type, Value, Location)
#define YY_STACK_PRINT(Bottom, Top)
#define YY_REDUCE_PRINT(Rule)
#define YYINITDEPTH   200
#define YYMAXDEPTH   10000
#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))

Typedefs

typedef struct _TABLE TABLE
typedef enum _DSTMODE DSTMODE
typedef enum _MERIDIAN MERIDIAN
typedef union YYSTYPE YYSTYPE
typedef unsigned char yytype_uint8
typedef short int yytype_int8
typedef unsigned short int yytype_uint16
typedef short int yytype_int16

Enumerations

enum  _DSTMODE { DSTon, DSToff, DSTmaybe }
enum  _MERIDIAN { MERam, MERpm, MER24 }
enum  yytokentype {
  tDAY = 258, tDAYZONE = 259, tMERIDIAN = 260, tMONTH = 261,
  tMONTH_UNIT = 262, tSEC_UNIT = 263, tSNUMBER = 264, tUNUMBER = 265,
  tZONE = 266
}

Functions

int date_lex (void)
static void date_error (char *)
static void yydestruct (char *yymsg, int yytype, YYSTYPE *yyvaluep) const
int yyparse ()
static time_t ToSeconds (time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian)
static time_t Convert (time_t Month, time_t Day, time_t Year, time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian, DSTMODE dst)
static time_t DSTcorrect (time_t Start, time_t Future)
static time_t RelativeMonth (time_t Start, time_t RelMonth)
static int LookupWord (char *buff, register int length)
time_t parsedate (const char *p)

Variables

static const char * yyInput
static DSTMODE yyDSTmode
static int yyHaveDate
static int yyHaveRel
static int yyHaveTime
static time_t yyTimezone
static time_t yyDay
static time_t yyHour
static time_t yyMinutes
static time_t yyMonth
static time_t yySeconds
static time_t yyYear
static MERIDIAN yyMeridian
static time_t yyRelMonth
static time_t yyRelSeconds
static const yytype_uint8 yytranslate []
static const yytype_uint8 yyr1 []
static const yytype_uint8 yyr2 []
static const yytype_uint8 yydefact []
static const yytype_int8 yydefgoto []
static const yytype_int8 yypact []
static const yytype_int8 yypgoto []
static const yytype_uint8 yytable []
static const yytype_int8 yycheck []
static const yytype_uint8 yystos []
int yychar
YYSTYPE yylval
int yynerrs
static TABLE MonthDayTable []
static TABLE UnitsTable []
static TABLE TimezoneTable []

Class Documentation

struct _TABLE

Definition at line 148 of file parsedate.c.

Class Members
char * name
int type
time_t value
union YYSTYPE

Definition at line 248 of file parsedate.c.

Class Members
time_t Number
union yyalloc

Definition at line 433 of file parsedate.c.

Collaboration diagram for yyalloc:
Class Members
yytype_int16 yyss_alloc
YYSTYPE yyvs_alloc

Define Documentation

#define DST_OFFSET   1

Definition at line 132 of file parsedate.c.

#define END_OF_TIME   2038

Definition at line 130 of file parsedate.c.

#define ENDOF (   array)    (&array[SIZEOF(array)])

Definition at line 142 of file parsedate.c.

#define EPOCH   1970

Definition at line 129 of file parsedate.c.

#define HOUR (   x)    (x * 60)

Definition at line 135 of file parsedate.c.

#define IS7BIT (   x)    ((unsigned int)(x) < 0200)

Definition at line 139 of file parsedate.c.

#define LPAREN   '('

Definition at line 137 of file parsedate.c.

#define RPAREN   ')'

Definition at line 138 of file parsedate.c.

#define SECSPERDAY   (24L * 60L * 60L)

Definition at line 133 of file parsedate.c.

#define SIZEOF (   array)    ((int)(sizeof array / sizeof array[0]))

Definition at line 141 of file parsedate.c.

#define tDAY   258

Definition at line 234 of file parsedate.c.

#define tDAYZONE   259

Definition at line 235 of file parsedate.c.

#define tMERIDIAN   260

Definition at line 236 of file parsedate.c.

#define tMONTH   261

Definition at line 237 of file parsedate.c.

#define tMONTH_UNIT   262

Definition at line 238 of file parsedate.c.

#define tSEC_UNIT   263

Definition at line 239 of file parsedate.c.

#define tSNUMBER   264

Definition at line 240 of file parsedate.c.

#define tUNUMBER   265

Definition at line 241 of file parsedate.c.

#define tZONE   266

Definition at line 242 of file parsedate.c.

#define YY_ (   msgid)    msgid

Definition at line 329 of file parsedate.c.

#define YY_LOCATION_PRINT (   File,
  Loc 
)    ((void) 0)

Definition at line 769 of file parsedate.c.

#define YY_REDUCE_PRINT (   Rule)

Definition at line 941 of file parsedate.c.

#define YY_STACK_PRINT (   Bottom,
  Top 
)

Definition at line 940 of file parsedate.c.

#define YY_SYMBOL_PRINT (   Title,
  Type,
  Value,
  Location 
)

Definition at line 939 of file parsedate.c.

#define YYABORT   goto yyabortlab

Definition at line 698 of file parsedate.c.

#define YYACCEPT   goto yyacceptlab

Definition at line 697 of file parsedate.c.

#define YYBACKUP (   Token,
  Value 
)
Value:
do                                                      \
  if (yychar == YYEMPTY && yylen == 1)                         \
    {                                                   \
      yychar = (Token);                                        \
      yylval = (Value);                                        \
      YYPOPSTACK (1);                                          \
      goto yybackup;                                    \
    }                                                   \
  else                                                  \
    {                                                   \
      yyerror (YY_("syntax error: cannot back up")); \
      YYERROR;                                                 \
    }                                                   \
while (YYID (0))

Definition at line 719 of file parsedate.c.

#define YYBISON   1

Definition at line 44 of file parsedate.c.

#define YYBISON_VERSION   "2.5"

Definition at line 47 of file parsedate.c.

#define yyclearin   (yychar = YYEMPTY)

Definition at line 693 of file parsedate.c.

#define YYCOPY (   To,
  From,
  Count 
)
Value:
do                                 \
       {                                  \
         YYSIZE_T yyi;                           \
         for (yyi = 0; yyi < (Count); yyi++)     \
           (To)[yyi] = (From)[yyi];              \
       }                                  \
      while (YYID (0))

Definition at line 476 of file parsedate.c.

#define YYCOPY_NEEDED   1

Definition at line 448 of file parsedate.c.

#define YYDEBUG   0

Definition at line 199 of file parsedate.c.

#define YYDPRINTF (   Args)

Definition at line 938 of file parsedate.c.

#define YYEMPTY   (-2)

Definition at line 694 of file parsedate.c.

#define YYEOF   0

Definition at line 695 of file parsedate.c.

#define YYERRCODE   256

Definition at line 737 of file parsedate.c.

#define yyerrok   (yyerrstatus = 0)

Definition at line 692 of file parsedate.c.

#define yyerror   date_error

Definition at line 125 of file parsedate.c.

#define YYERROR   goto yyerrorlab

Definition at line 699 of file parsedate.c.

#define YYERROR_VERBOSE   0

Definition at line 207 of file parsedate.c.

#define YYFAIL   goto yyerrlab

Definition at line 709 of file parsedate.c.

#define YYFINAL   2

Definition at line 489 of file parsedate.c.

#define YYFREE   free

Definition at line 418 of file parsedate.c.

#define YYID (   n)    (n)

Definition at line 342 of file parsedate.c.

#define YYINITDEPTH   200

Definition at line 947 of file parsedate.c.

#define YYLAST   40

Definition at line 491 of file parsedate.c.

#define yylex   date_lex

Definition at line 124 of file parsedate.c.

#define YYLEX   yylex ()

Definition at line 778 of file parsedate.c.

#define YYLLOC_DEFAULT (   Current,
  Rhs,
  N 
)
Value:
do                                                             \
      if (YYID (N))                                                    \
       {                                                       \
         (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;       \
         (Current).first_column = YYRHSLOC (Rhs, 1).first_column;     \
         (Current).last_line    = YYRHSLOC (Rhs, N).last_line;        \
         (Current).last_column  = YYRHSLOC (Rhs, N).last_column;      \
       }                                                       \
      else                                                     \
       {                                                       \
         (Current).first_line   = (Current).last_line   =             \
           YYRHSLOC (Rhs, 0).last_line;                        \
         (Current).first_column = (Current).last_column =             \
           YYRHSLOC (Rhs, 0).last_column;                      \
       }                                                       \
    while (YYID (0))

Definition at line 746 of file parsedate.c.

#define YYLSP_NEEDED   0

Definition at line 62 of file parsedate.c.

#define YYMALLOC   malloc

Definition at line 411 of file parsedate.c.

#define YYMAXDEPTH   10000

Definition at line 958 of file parsedate.c.

#define YYMAXUTOK   266

Definition at line 504 of file parsedate.c.

#define YYNNTS   9

Definition at line 496 of file parsedate.c.

#define YYNRULES   30

Definition at line 498 of file parsedate.c.

#define YYNSTATES   44

Definition at line 500 of file parsedate.c.

#define YYNTOKENS   15

Definition at line 494 of file parsedate.c.

#define YYPACT_NINF   -29

Definition at line 637 of file parsedate.c.

#define yypact_value_is_default (   yystate)    ((yystate) == (-29))

Definition at line 666 of file parsedate.c.

int yyparse   date_parse

Definition at line 123 of file parsedate.c.

#define YYPOPSTACK (   N)    (yyvsp -= (N), yyssp -= (N))
#define YYPULL   1

Definition at line 59 of file parsedate.c.

#define YYPURE   0

Definition at line 53 of file parsedate.c.

#define YYPUSH   0

Definition at line 56 of file parsedate.c.

#define YYRECOVERING ( )    (!!yyerrstatus)

Definition at line 717 of file parsedate.c.

#define YYRHSLOC (   Rhs,
 
)    ((Rhs)[K])

Definition at line 744 of file parsedate.c.

#define YYSIZE_MAXIMUM   ((YYSIZE_T) -1)

Definition at line 319 of file parsedate.c.

#define YYSIZE_T   unsigned int

Definition at line 315 of file parsedate.c.

#define YYSKELETON_NAME   "yacc.c"

Definition at line 50 of file parsedate.c.

#define YYSTACK_ALLOC   YYMALLOC

Definition at line 397 of file parsedate.c.

Definition at line 400 of file parsedate.c.

#define YYSTACK_BYTES (   N)
Value:
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
      + YYSTACK_GAP_MAXIMUM)

Definition at line 444 of file parsedate.c.

#define YYSTACK_FREE   YYFREE

Definition at line 398 of file parsedate.c.

#define YYSTACK_GAP_MAXIMUM   (sizeof (union yyalloc) - 1)

Definition at line 440 of file parsedate.c.

#define YYSTACK_RELOCATE (   Stack_alloc,
  Stack 
)
Value:
do                                                             \
      {                                                               \
       YYSIZE_T yynewbytes;                                    \
       YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                   \
       Stack = &yyptr->Stack_alloc;                                   \
       yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
       yyptr += yynewbytes / sizeof (*yyptr);                         \
      }                                                               \
    while (YYID (0))

Definition at line 455 of file parsedate.c.

#define yystype   YYSTYPE /* obsolescent; will be withdrawn */

Definition at line 263 of file parsedate.c.

#define YYSTYPE_IS_DECLARED   1

Definition at line 264 of file parsedate.c.

#define YYSTYPE_IS_TRIVIAL   1

Definition at line 262 of file parsedate.c.

#define YYTABLE_NINF   -1

Definition at line 656 of file parsedate.c.

#define yytable_value_is_error (   yytable_value)    YYID (0)

Definition at line 669 of file parsedate.c.

#define YYTERROR   1

Definition at line 736 of file parsedate.c.

#define YYTOKEN_TABLE   0

Definition at line 212 of file parsedate.c.

#define YYTOKENTYPE

Definition at line 218 of file parsedate.c.

#define YYTRANSLATE (   YYX)    ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)

Definition at line 506 of file parsedate.c.

#define YYUNDEFTOK   2

Definition at line 503 of file parsedate.c.

#define YYUSE (   e)    ((void) (e))

Definition at line 335 of file parsedate.c.


Typedef Documentation

typedef enum _DSTMODE DSTMODE
typedef enum _MERIDIAN MERIDIAN
typedef struct _TABLE TABLE
typedef union YYSTYPE YYSTYPE
typedef short int yytype_int16

Definition at line 302 of file parsedate.c.

typedef short int yytype_int8

Definition at line 290 of file parsedate.c.

typedef unsigned short int yytype_uint16

Definition at line 296 of file parsedate.c.

typedef unsigned char yytype_uint8

Definition at line 281 of file parsedate.c.


Enumeration Type Documentation

enum _DSTMODE
Enumerator:
DSTon 
DSToff 
DSTmaybe 

Definition at line 157 of file parsedate.c.

enum _MERIDIAN
Enumerator:
MERam 
MERpm 
MER24 

Definition at line 164 of file parsedate.c.

Enumerator:
tDAY 
tDAYZONE 
tMERIDIAN 
tMONTH 
tMONTH_UNIT 
tSEC_UNIT 
tSNUMBER 
tUNUMBER 
tZONE 

Definition at line 221 of file parsedate.c.

                    {
     tDAY = 258,
     tDAYZONE = 259,
     tMERIDIAN = 260,
     tMONTH = 261,
     tMONTH_UNIT = 262,
     tSEC_UNIT = 263,
     tSNUMBER = 264,
     tUNUMBER = 265,
     tZONE = 266
   };

Function Documentation

static time_t Convert ( time_t  Month,
time_t  Day,
time_t  Year,
time_t  Hours,
time_t  Minutes,
time_t  Seconds,
MERIDIAN  Meridian,
DSTMODE  dst 
) [static]

Definition at line 2257 of file parsedate.c.

{
    static int       DaysNormal[13] = {
       0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
    };
    static int       DaysLeap[13] = {
       0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
    };
    static int       LeapYears[] = {
       1972, 1976, 1980, 1984, 1988, 1992, 1996,
       2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036
    };
    register int     *yp;
    register int     *mp;
    register time_t  Julian;
    register int     i;
    time_t           tod;

    if (Year < 0)
       Year = -Year;
    if (Year < 100)
       Year += 1900;
    if (Year < EPOCH)
       Year += 100;
    for (mp = DaysNormal, yp = LeapYears; yp < ENDOF(LeapYears); yp++)
       if (Year == *yp) {
           mp = DaysLeap;
           break;
       }
    if (Year < EPOCH || Year > END_OF_TIME
     || Month < 1 || Month > 12
     /* NOSTRICT *//* conversion from long may lose accuracy */
     || Day < 1 || Day > mp[(int)Month])
       return -1;

    Julian = Day - 1 + (Year - EPOCH) * 365;
    for (yp = LeapYears; yp < ENDOF(LeapYears); yp++, Julian++)
       if (Year <= *yp)
           break;
    for (i = 1; i < Month; i++)
       Julian += *++mp;
    Julian *= SECSPERDAY;
    Julian += yyTimezone * 60L;
    if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
       return -1;
    Julian += tod;
    tod = Julian;
    if (dst == DSTon || (dst == DSTmaybe && localtime(&tod)->tm_isdst))
       Julian -= DST_OFFSET * 60L * 60L;
    return Julian;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void date_error ( char *  s) [static]

Definition at line 2229 of file parsedate.c.

{
    /* NOTREACHED */
}
int date_lex ( void  )

Definition at line 2433 of file parsedate.c.

{
    register char    c;
    register char    *p;
    char             buff[20];
    register int     sign;
    register int     i;
    register int     nesting;

    for ( ; ; ) {
       /* Get first character after the whitespace. */
       for ( ; ; ) {
           while (isspace(*yyInput))
              yyInput++;
           c = *yyInput;

           /* Ignore RFC 822 comments, typically time zone names. */
           if (c != LPAREN)
              break;
           for (nesting = 1; (c = *++yyInput) != RPAREN || --nesting; )
              if (c == LPAREN)
                  nesting++;
              else if (!IS7BIT(c) || c == '\0' || c == '\r'
                   || (c == '\\' && ((c = *++yyInput) == '\0' || !IS7BIT(c))))
                  /* Lexical error: bad comment. */
                  return '?';
           yyInput++;
       }

       /* A number? */
       if (isdigit(c) || c == '-' || c == '+') {
           if (c == '-' || c == '+') {
              sign = c == '-' ? -1 : 1;
              yyInput++;
              if (!isdigit(*yyInput))
                  /* Skip the plus or minus sign. */
                  continue;
           }
           else
              sign = 0;
           for (i = 0; (c = *yyInput++) != '\0' && isdigit(c); )
              i = 10 * i + c - '0';
           yyInput--;
           yylval.Number = sign < 0 ? -i : i;
           return sign ? tSNUMBER : tUNUMBER;
       }

       /* A word? */
       if (isalpha(c)) {
           for (p = buff; (c = *yyInput++) == '.' || isalpha(c); )
              if (p < &buff[sizeof buff - 1])
                  *p++ = isupper(c) ? tolower(c) : c;
           *p = '\0';
           yyInput--;
           return LookupWord(buff, p - buff);
       }

       return *yyInput++;
    }
}

Here is the call graph for this function:

static time_t DSTcorrect ( time_t  Start,
time_t  Future 
) [static]

Definition at line 2313 of file parsedate.c.

{
    time_t    StartDay;
    time_t    FutureDay;

    StartDay = (localtime(&Start)->tm_hour + 1) % 24;
    FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
    return (Future - Start) + (StartDay - FutureDay) * DST_OFFSET * 60L * 60L;
}

Here is the caller graph for this function:

static int LookupWord ( char *  buff,
register int  length 
) [static]

Definition at line 2343 of file parsedate.c.

{
    register char    *p;
    register char    *q;
    register TABLE   *tp;
    register int     c;

    p = buff;
    c = p[0];

    /* See if we have an abbreviation for a month. */
    if (length == 3 || (length == 4 && p[3] == '.'))
       for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++) {
           q = tp->name;
           if (c == q[0] && p[1] == q[1] && p[2] == q[2]) {
              yylval.Number = tp->value;
              return tp->type;
           }
       }
    else
       for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++)
           if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
              yylval.Number = tp->value;
              return tp->type;
           }

    /* Try for a timezone. */
    for (tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
       if (c == tp->name[0] && p[1] == tp->name[1]
        && strcmp(p, tp->name) == 0) {
           yylval.Number = tp->value;
           return tp->type;
       }

    /* Try the units table. */
    for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
       if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
           yylval.Number = tp->value;
           return tp->type;
       }

    /* Strip off any plural and try the units table again. */
    if (--length > 0 && p[length] == 's') {
       p[length] = '\0';
       for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
           if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
              p[length] = 's';
              yylval.Number = tp->value;
              return tp->type;
           }
       p[length] = 's';
    }
    length++;

    /* Drop out any periods. */
    for (p = buff, q = (char*)buff; *q; q++)
       if (*q != '.')
           *p++ = *q;
    *p = '\0';

    /* Try the meridians. */
    if (buff[1] == 'm' && buff[2] == '\0') {
       if (buff[0] == 'a') {
           yylval.Meridian = MERam;
           return tMERIDIAN;
       }
       if (buff[0] == 'p') {
           yylval.Meridian = MERpm;
           return tMERIDIAN;
       }
    }

    /* If we saw any periods, try the timezones again. */
    if (p - buff != length) {
       c = buff[0];
       for (p = buff, tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
           if (c == tp->name[0] && p[1] == tp->name[1]
           && strcmp(p, tp->name) == 0) {
              yylval.Number = tp->value;
              return tp->type;
           }
    }

    /* Unknown word -- assume GMT timezone. */
    yylval.Number = 0;
    return tZONE;
}

Here is the caller graph for this function:

time_t parsedate ( const char *  p)

Definition at line 2496 of file parsedate.c.

{
    extern int              date_parse(void);
    time_t           Start;

    yyInput = p; /* well, its supposed to be const... */

    yyYear = 0;
    yyMonth = 0;
    yyDay = 0;
    yyTimezone = 0;
    yyDSTmode = DSTmaybe;
    yyHour = 0;
    yyMinutes = 0;
    yySeconds = 0;
    yyMeridian = MER24;
    yyRelSeconds = 0;
    yyRelMonth = 0;
    yyHaveDate = 0;
    yyHaveRel = 0;
    yyHaveTime = 0;

    if (date_parse() || yyHaveTime > 1 || yyHaveDate > 1)
       return -1;

    if (yyHaveDate || yyHaveTime) {
       Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
                  yyMeridian, yyDSTmode);
       if (Start < 0)
           return -1;
    }
    else
       return -1;

    Start += yyRelSeconds;
    if (yyRelMonth)
       Start += RelativeMonth(Start, yyRelMonth);

    /* Have to do *something* with a legitimate -1 so it's distinguishable
     * from the error return value.  (Alternately could set errno on error.) */
    return Start == -1 ? 0 : Start;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static time_t RelativeMonth ( time_t  Start,
time_t  RelMonth 
) [static]

Definition at line 2325 of file parsedate.c.

{
    struct tm *tm;
    time_t    Month;
    time_t    Year;

    tm = localtime(&Start);
    Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
    Year = Month / 12;
    Month = Month % 12 + 1;
    return DSTcorrect(Start,
           Convert(Month, (time_t)tm->tm_mday, Year,
              (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
              MER24, DSTmaybe));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static time_t ToSeconds ( time_t  Hours,
time_t  Minutes,
time_t  Seconds,
MERIDIAN  Meridian 
) [static]

Definition at line 2236 of file parsedate.c.

{
    if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 61)
       return -1;
    if (Meridian == MER24) {
       if (Hours < 0 || Hours > 23)
           return -1;
    }
    else {
       if (Hours < 1 || Hours > 12)
           return -1;
       if (Hours == 12)
           Hours = 0;
       if (Meridian == MERpm)
           Hours += 12;
    }
    return (Hours * 60L + Minutes) * 60L + Seconds;
}

Here is the caller graph for this function:

static void yydestruct ( char *  yymsg,
int  yytype,
YYSTYPE yyvaluep 
) const [static]

Definition at line 1211 of file parsedate.c.

{
  YYUSE (yyvaluep);

  if (!yymsg)
    yymsg = "Deleting";
  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);

  switch (yytype)
    {

      default:
       break;
    }
}
int yyparse ( )

Variable Documentation

TABLE MonthDayTable[] [static]
Initial value:
 {
    { "january",     tMONTH,  1 },
    { "february",    tMONTH,  2 },
    { "march",              tMONTH,  3 },
    { "april",              tMONTH,  4 },
    { "may",         tMONTH,  5 },
    { "june",        tMONTH,  6 },
    { "july",        tMONTH,  7 },
    { "august",             tMONTH,  8 },
    { "september",   tMONTH,  9 },
    { "october",     tMONTH, 10 },
    { "november",    tMONTH, 11 },
    { "december",    tMONTH, 12 },
       
    { "sunday",             tDAY, 0 },
    { "monday",             tDAY, 0 },
    { "tuesday",     tDAY, 0 },
    { "wednesday",   tDAY, 0 },
    { "thursday",    tDAY, 0 },
    { "friday",             tDAY, 0 },
    { "saturday",    tDAY, 0 },
}

Definition at line 2077 of file parsedate.c.

TABLE TimezoneTable[] [static]

Definition at line 2114 of file parsedate.c.

TABLE UnitsTable[] [static]
Initial value:
 {
    { "year",        tMONTH_UNIT,  12 },
    { "month",              tMONTH_UNIT,  1 },
    { "week",        tSEC_UNIT,    7L * 24 * 60 * 60 },
    { "day",         tSEC_UNIT,    1L * 24 * 60 * 60 },
    { "hour",        tSEC_UNIT,    60 * 60 },
    { "minute",             tSEC_UNIT,    60 },
    { "min",         tSEC_UNIT,    60 },
    { "second",             tSEC_UNIT,    1 },
    { "sec",         tSEC_UNIT,    1 },
}

Definition at line 2101 of file parsedate.c.

int yychar

Definition at line 1249 of file parsedate.c.

const yytype_int8 yycheck[] [static]
Initial value:
{
      24,     0,    30,    14,     3,     5,    30,     6,     4,     9,
       9,    10,    40,     9,     9,    11,    40,     5,     6,     7,
       8,    10,     5,    10,    12,    13,     9,     7,     8,    12,
      14,    10,    10,    10,     6,    10,    10,    13,    -1,    10,
      10
}

Definition at line 672 of file parsedate.c.

time_t yyDay [static]

Definition at line 180 of file parsedate.c.

const yytype_uint8 yydefact[] [static]
Initial value:
{
       2,     0,     1,     0,     0,     0,    29,     3,     4,     6,
       7,     0,    20,    27,    25,    30,    22,    28,    26,     0,
       0,     8,    14,    17,    13,     5,    16,     0,     0,    23,
      29,    18,    15,     0,    21,     0,    10,     9,     0,    24,
      29,    19,    12,    11
}

Definition at line 620 of file parsedate.c.

const yytype_int8 yydefgoto[] [static]
Initial value:
{
      -1,     1,     7,     8,    25,    26,     9,    10,    21
}

Definition at line 630 of file parsedate.c.

DSTMODE yyDSTmode [static]

Definition at line 175 of file parsedate.c.

int yyHaveDate [static]

Definition at line 176 of file parsedate.c.

int yyHaveRel [static]

Definition at line 177 of file parsedate.c.

int yyHaveTime [static]

Definition at line 178 of file parsedate.c.

time_t yyHour [static]

Definition at line 181 of file parsedate.c.

const char* yyInput [static]

Definition at line 174 of file parsedate.c.

Definition at line 1252 of file parsedate.c.

MERIDIAN yyMeridian [static]

Definition at line 186 of file parsedate.c.

time_t yyMinutes [static]

Definition at line 182 of file parsedate.c.

time_t yyMonth [static]

Definition at line 183 of file parsedate.c.

int yynerrs

Definition at line 1255 of file parsedate.c.

const yytype_int8 yypact[] [static]
Initial value:
{
     -29,     1,   -29,   -11,    11,    20,    12,   -29,     4,   -29,
     -29,    13,    16,   -29,   -29,   -29,    21,   -29,   -29,    22,
      23,   -29,   -29,   -29,     5,   -29,   -29,    28,    25,   -29,
      17,    24,   -29,    26,   -29,    29,   -29,   -29,    30,   -29,
       0,   -29,   -29,   -29
}

Definition at line 638 of file parsedate.c.

const yytype_int8 yypgoto[] [static]
Initial value:
{
     -29,   -29,   -29,   -29,   -29,   -24,   -29,   -29,   -28
}

Definition at line 648 of file parsedate.c.

const yytype_uint8 yyr1[] [static]
Initial value:
{
       0,    15,    16,    16,    17,    17,    17,    17,    18,    18,
      18,    18,    18,    19,    19,    19,    19,    20,    21,    21,
      21,    21,    21,    21,    21,    22,    22,    22,    22,    23,
      23
}

Definition at line 600 of file parsedate.c.

const yytype_uint8 yyr2[] [static]
Initial value:
{
       0,     2,     0,     2,     1,     2,     1,     1,     2,     4,
       4,     6,     6,     1,     1,     2,     1,     1,     3,     5,
       2,     4,     2,     3,     5,     2,     2,     2,     2,     0,
       1
}

Definition at line 609 of file parsedate.c.

time_t yyRelMonth [static]

Definition at line 187 of file parsedate.c.

time_t yyRelSeconds [static]

Definition at line 188 of file parsedate.c.

time_t yySeconds [static]

Definition at line 184 of file parsedate.c.

const yytype_uint8 yystos[] [static]
Initial value:
{
       0,    16,     0,     3,     6,     9,    10,    17,    18,    21,
      22,    14,    10,     7,     8,     5,     6,     7,     8,    12,
      13,    23,     4,     9,    11,    19,    20,    10,    14,    10,
      10,    10,    20,     6,    10,    12,    20,    23,    13,    10,
      10,    10,    20,    23
}

Definition at line 683 of file parsedate.c.

const yytype_uint8 yytable[] [static]
Initial value:
{
      32,     2,    37,    11,     3,    15,    36,     4,    22,    23,
       5,     6,    43,    23,    23,    24,    42,    15,    16,    17,
      18,    12,    15,    27,    19,    20,    23,    13,    14,    35,
      28,    29,    30,    31,    33,    34,    39,    38,     0,    40,
      41
}

Definition at line 657 of file parsedate.c.

time_t yyTimezone [static]

Definition at line 179 of file parsedate.c.

const yytype_uint8 yytranslate[] [static]
Initial value:
{
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,    14,     2,     2,    13,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,    12,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
       5,     6,     7,     8,     9,    10,    11
}

Definition at line 510 of file parsedate.c.

time_t yyYear [static]

Definition at line 185 of file parsedate.c.