186d7f5d3SJohn Marino /* Parse a string, yielding a struct partime that describes it. */ 286d7f5d3SJohn Marino 386d7f5d3SJohn Marino /* Copyright 1993, 1994, 1995 Paul Eggert 486d7f5d3SJohn Marino Distributed under license by the Free Software Foundation, Inc. 586d7f5d3SJohn Marino 686d7f5d3SJohn Marino This file is part of RCS. 786d7f5d3SJohn Marino 886d7f5d3SJohn Marino RCS is free software; you can redistribute it and/or modify 986d7f5d3SJohn Marino it under the terms of the GNU General Public License as published by 1086d7f5d3SJohn Marino the Free Software Foundation; either version 2, or (at your option) 1186d7f5d3SJohn Marino any later version. 1286d7f5d3SJohn Marino 1386d7f5d3SJohn Marino RCS is distributed in the hope that it will be useful, 1486d7f5d3SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of 1586d7f5d3SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1686d7f5d3SJohn Marino GNU General Public License for more details. 1786d7f5d3SJohn Marino 1886d7f5d3SJohn Marino You should have received a copy of the GNU General Public License 1986d7f5d3SJohn Marino along with RCS; see the file COPYING. 2086d7f5d3SJohn Marino If not, write to the Free Software Foundation, 2186d7f5d3SJohn Marino 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 2286d7f5d3SJohn Marino 2386d7f5d3SJohn Marino Report problems and direct all questions to: 2486d7f5d3SJohn Marino 2586d7f5d3SJohn Marino rcs-bugs@cs.purdue.edu 2686d7f5d3SJohn Marino 2786d7f5d3SJohn Marino */ 2886d7f5d3SJohn Marino 2986d7f5d3SJohn Marino #define TM_UNDEFINED (-1) 3086d7f5d3SJohn Marino #define TM_DEFINED(x) (0 <= (x)) 3186d7f5d3SJohn Marino 3286d7f5d3SJohn Marino #define TM_UNDEFINED_ZONE ((long) -24 * 60 * 60) 3386d7f5d3SJohn Marino #define TM_LOCAL_ZONE (TM_UNDEFINED_ZONE - 1) 3486d7f5d3SJohn Marino 3586d7f5d3SJohn Marino struct partime { 3686d7f5d3SJohn Marino /* 3786d7f5d3SJohn Marino * This structure describes the parsed time. 3886d7f5d3SJohn Marino * Only the following tm_* values in it are used: 3986d7f5d3SJohn Marino * sec, min, hour, mday, mon, year, wday, yday. 4086d7f5d3SJohn Marino * If TM_UNDEFINED(value), the parser never found the value. 4186d7f5d3SJohn Marino * The tm_year field is the actual year, not the year - 1900; 4286d7f5d3SJohn Marino * but see ymodulus below. 4386d7f5d3SJohn Marino */ 4486d7f5d3SJohn Marino struct tm tm; 4586d7f5d3SJohn Marino 4686d7f5d3SJohn Marino /* 4786d7f5d3SJohn Marino * If !TM_UNDEFINED(ymodulus), 4886d7f5d3SJohn Marino * then tm.tm_year is actually modulo ymodulus. 4986d7f5d3SJohn Marino */ 5086d7f5d3SJohn Marino int ymodulus; 5186d7f5d3SJohn Marino 5286d7f5d3SJohn Marino /* 5386d7f5d3SJohn Marino * Week of year, ISO 8601 style. 5486d7f5d3SJohn Marino * If TM_UNDEFINED(yweek), the parser never found yweek. 5586d7f5d3SJohn Marino * Weeks start on Mondays. 5686d7f5d3SJohn Marino * Week 1 includes Jan 4. 5786d7f5d3SJohn Marino */ 5886d7f5d3SJohn Marino int yweek; 5986d7f5d3SJohn Marino 6086d7f5d3SJohn Marino /* Seconds east of UTC; or TM_LOCAL_ZONE or TM_UNDEFINED_ZONE. */ 6186d7f5d3SJohn Marino long zone; 6286d7f5d3SJohn Marino }; 6386d7f5d3SJohn Marino 6486d7f5d3SJohn Marino #if defined(__STDC__) || has_prototypes 6586d7f5d3SJohn Marino # define __PARTIME_P(x) x 6686d7f5d3SJohn Marino #else 6786d7f5d3SJohn Marino # define __PARTIME_P(x) () 6886d7f5d3SJohn Marino #endif 6986d7f5d3SJohn Marino 7086d7f5d3SJohn Marino char *partime __PARTIME_P((char const *, struct partime *)); 7186d7f5d3SJohn Marino char *parzone __PARTIME_P((char const *, long *)); 72