1 /******************************************************************************
2  * $Id$
3  *
4  * Project:  MapServer
5  * Purpose:  Time processing related declarations.
6  * Author:   Steve Lime and the MapServer team.
7  *
8  ******************************************************************************
9  * Copyright (c) 1996-2005 Regents of the University of Minnesota.
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included in
19  * all copies of this Software or works derived from this Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  ****************************************************************************/
29 
30 #ifndef MAPTIME_H
31 #define MAPTIME_H
32 
33 /* (bug 602) gettimeofday() and struct timeval aren't available on Windows,
34  * so we provide a replacement with msGettimeofday() and struct mstimeval on
35  * Windows.  On Unix/Linux they are just #defines to the real things.
36  */
37 #if defined(_WIN32) && !defined(__CYGWIN__)
38 struct mstimeval {
39   long    tv_sec;         /* seconds */
40   long    tv_usec;        /* and microseconds */
41 };
42 MS_DLL_EXPORT void msGettimeofday(struct mstimeval *t, void *__not_used_here__);
43 #else
44 #  include <sys/time.h>     /* for gettimeofday() */
45 #  define  mstimeval timeval
46 #  define  msGettimeofday(t,u) gettimeofday(t,u)
47 #endif
48 
49 typedef enum {
50   TIME_RESOLUTION_UNDEFINED = -1,
51   TIME_RESOLUTION_MICROSECOND =0,
52   TIME_RESOLUTION_MILLISECOND =1,
53   TIME_RESOLUTION_SECOND =2,
54   TIME_RESOLUTION_MINUTE =3,
55   TIME_RESOLUTION_HOUR =4,
56   TIME_RESOLUTION_DAY =5,
57   TIME_RESOLUTION_MONTH =6,
58   TIME_RESOLUTION_YEAR =7
59 } MS_TIME_RESOLUTION;
60 
61 /* function prototypes */
62 void msTimeInit(struct tm *time);
63 int msDateCompare(struct tm *time1, struct tm *time2);
64 int msTimeCompare(struct tm *time1, struct tm *time2);
65 char *msStrptime(const char *s, const char *format, struct tm *tm);
66 int msParseTime(const char *string, struct tm *tm);
67 int msTimeMatchPattern(const char *timestring, const char *pattern);
68 void msSetLimitedPatternsToUse(const char *patternstring);
69 void msUnsetLimitedPatternToUse(void);
70 MS_DLL_EXPORT int msTimeGetResolution(const char *timestring);
71 void msTimeCleanup();
72 
73 int msValidateTimeValue(const char *timestring, const char *timeextent);
74 
75 #endif /* MAPTIME_H */
76