Permalink
Browse files

Changed date/time patterns to have end-of-line anchors ($). Fixed a m…

…isspelling in one of the time API function names.
  • Loading branch information...
sdlime committed Sep 17, 2014
1 parent 2d312c5 commit 0cc47e3027a75cf18c5310694877999c6b245371
Showing with 20 additions and 22 deletions.
  1. +19 −21 maptime.c
  2. +1 −1 maptime.h
View
@@ -1,5 +1,5 @@
/******************************************************************************
* $Id$
* $id$
*
* Project: MapServer
* Purpose: Date/Time utility functions.
@@ -46,22 +46,23 @@ typedef struct {
MS_TIME_RESOLUTION resolution;
} timeFormatObj;
#define MS_NUMTIMEFORMATS 13
#define MS_NUMTIMEFORMATS 14
timeFormatObj ms_timeFormats[MS_NUMTIMEFORMATS] = {
{"^[0-9]{8}", NULL, "%Y%m%d","YYYYMMDD",TIME_RESOLUTION_DAY},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z", NULL, "%Y-%m-%dT%H:%M:%SZ","YYYY-MM-DDTHH:MM:SSZ",TIME_RESOLUTION_SECOND},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}", NULL, "%Y-%m-%dT%H:%M:%S", "YYYY-MM-DDTHH:MM:SS",TIME_RESOLUTION_SECOND},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}", NULL, "%Y-%m-%d %H:%M:%S", "YYYY-MM-DD HH:MM:SS", TIME_RESOLUTION_SECOND},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}", NULL, "%Y-%m-%dT%H:%M", "YYYY-MM-DDTHH:MM",TIME_RESOLUTION_MINUTE},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}", NULL, "%Y-%m-%d %H:%M", "YYYY-MM-DD HH:MM",TIME_RESOLUTION_MINUTE},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}", NULL, "%Y-%m-%dT%H", "YYYY-MM-DDTHH",TIME_RESOLUTION_HOUR},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}", NULL, "%Y-%m-%d %H", "YYYY-MM-DD HH",TIME_RESOLUTION_HOUR},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2}", NULL, "%Y-%m-%d", "YYYY-MM-DD", TIME_RESOLUTION_DAY},
{"^[0-9]{4}-[0-9]{2}", NULL, "%Y-%m", "YYYY-MM",TIME_RESOLUTION_MONTH},
{"^[0-9]{4}", NULL, "%Y", "YYYY",TIME_RESOLUTION_YEAR},
{"^T[0-9]{2}:[0-9]{2}:[0-9]{2}Z", NULL, "T%H:%M:%SZ", "THH:MM:SSZ",TIME_RESOLUTION_SECOND},
{"^T[0-9]{2}:[0-9]{2}:[0-9]{2}", NULL, "T%H:%M:%S", "THH:MM:SS", TIME_RESOLUTION_SECOND},
{"^[0-9]{4}$", NULL, "%Y", "YYYY", TIME_RESOLUTION_YEAR},
{"^[0-9]{4}-[0-9]{2}$", NULL, "%Y-%m", "YYYY-MM", TIME_RESOLUTION_MONTH},
{"^[0-9]{8}$", NULL, "%Y%m%d", "YYYYMMDD", TIME_RESOLUTION_DAY},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2}Z?$", NULL, "%Y-%m-%d", "YYYY-MM-DD", TIME_RESOLUTION_DAY},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$", NULL, "%Y-%m-%dT%H:%M:%SZ", "YYYY-MM-DDTHH:MM:SSZ", TIME_RESOLUTION_SECOND},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}Z$", NULL, "%Y-%m-%d %H:%M:%SZ", "YYYY-MM-DD HH:MM:SSZ", TIME_RESOLUTION_SECOND},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$", NULL, "%Y-%m-%dT%H:%M:%S", "YYYY-MM-DDTHH:MM:SS", TIME_RESOLUTION_SECOND},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$", NULL, "%Y-%m-%d %H:%M:%S", "YYYY-MM-DD HH:MM:SS", TIME_RESOLUTION_SECOND},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}$", NULL, "%Y-%m-%dT%H:%M", "YYYY-MM-DDTHH:MM", TIME_RESOLUTION_MINUTE},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$", NULL, "%Y-%m-%d %H:%M", "YYYY-MM-DD HH:MM", TIME_RESOLUTION_MINUTE},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}$", NULL, "%Y-%m-%dT%H", "YYYY-MM-DDTHH", TIME_RESOLUTION_HOUR},
{"^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}$", NULL, "%Y-%m-%d %H", "YYYY-MM-DD HH", TIME_RESOLUTION_HOUR},
{"^T[0-9]{2}:[0-9]{2}:[0-9]{2}Z", NULL, "T%H:%M:%SZ", "THH:MM:SSZ", TIME_RESOLUTION_SECOND},
{"^T[0-9]{2}:[0-9]{2}:[0-9]{2}", NULL, "T%H:%M:%S", "THH:MM:SS", TIME_RESOLUTION_SECOND}
};
int *ms_limited_pattern = NULL;
@@ -204,7 +205,7 @@ int msTimeMatchPattern(const char *timestring, const char *timeformat)
}
if (i >= 0 && i < MS_NUMTIMEFORMATS) {
int match = ms_regexec(ms_timeFormats[i].regex, timestring, 0,NULL, 0);
int match = ms_regexec(ms_timeFormats[i].regex, timestring, 0, NULL, 0);
if(match == 0)
return MS_TRUE;
}
@@ -218,7 +219,7 @@ void msUnsetLimitedPatternToUse()
ms_num_limited_pattern = 0;
}
void msSetLimitedPattersToUse(const char *patternstring)
void msSetLimitedPatternsToUse(const char *patternstring)
{
int *limitedpatternindice = NULL;
int numpatterns=0, i=0, j=0, ntmp=0;
@@ -256,8 +257,6 @@ void msSetLimitedPattersToUse(const char *patternstring)
free (limitedpatternindice);
}
int msParseTime(const char *string, struct tm *tm)
{
int i, indice = 0;
@@ -269,8 +268,7 @@ int msParseTime(const char *string, struct tm *tm)
return MS_FALSE;
}
/* if limited patterns are set, use then. Else use all the */
/* patterns defined */
/* if limited patterns are set, use them, else use all the patterns defined */
if (ms_num_limited_pattern > 0)
num_patterns = ms_num_limited_pattern;
else
View
@@ -65,7 +65,7 @@ int msTimeCompare(struct tm *time1, struct tm *time2);
char *msStrptime(const char *s, const char *format, struct tm *tm);
int msParseTime(const char *string, struct tm *tm);
int msTimeMatchPattern(const char *timestring, const char *pattern);
void msSetLimitedPattersToUse(const char *patternstring);
void msSetLimitedPatternsToUse(const char *patternstring);
void msUnsetLimitedPatternToUse(void);
MS_DLL_EXPORT int msTimeGetResolution(const char *timestring);
void msTimeCleanup();

3 comments on commit 0cc47e3

@geographika

This comment has been minimized.

Show comment
Hide comment
@geographika

geographika Dec 2, 2014

Contributor

I've just been testing a development build and run into some errors due (I think) to the above changes.

I pass in a TIME parameter through a WMS request, which worked fine in the 6.4 release. However now I get the following:

msWMSApplyTime: WMS server error. Time value(s) 2008-01-01/2020-12-31,1900-1-1/1900-1-1 given is invalid or outside the time extent defined (1900-1-1/2030-12-31).
msParseTime(): Regular expression error. Unrecognized date or time format (1900-1-1).

My metadata for the layer includes:

"ows_timeextent" "1900-1-1/2030-12-31"

My WMS request includes the following time range as part of the querystring:

TIME=2008-1-1/2020-12-31

I am using a Windows server (so line endings in the .map file are Windows style). Changing these to UNIX style line endings did not make a difference.

Contributor

geographika replied Dec 2, 2014

I've just been testing a development build and run into some errors due (I think) to the above changes.

I pass in a TIME parameter through a WMS request, which worked fine in the 6.4 release. However now I get the following:

msWMSApplyTime: WMS server error. Time value(s) 2008-01-01/2020-12-31,1900-1-1/1900-1-1 given is invalid or outside the time extent defined (1900-1-1/2030-12-31).
msParseTime(): Regular expression error. Unrecognized date or time format (1900-1-1).

My metadata for the layer includes:

"ows_timeextent" "1900-1-1/2030-12-31"

My WMS request includes the following time range as part of the querystring:

TIME=2008-1-1/2020-12-31

I am using a Windows server (so line endings in the .map file are Windows style). Changing these to UNIX style line endings did not make a difference.

@sdlime

This comment has been minimized.

Show comment
Hide comment
@sdlime

sdlime Dec 2, 2014

Member

@geographika, thanks for the comment. Can you create a regular ticket? Ideally a small test case would really help and I'll take a look. It may be that the ranges need to be broken into constituent pieces before being valldated. --Steve

Member

sdlime replied Dec 2, 2014

@geographika, thanks for the comment. Can you create a regular ticket? Ideally a small test case would really help and I'll take a look. It may be that the ranges need to be broken into constituent pieces before being valldated. --Steve

@geographika

This comment has been minimized.

Show comment
Hide comment
@geographika

geographika Dec 3, 2014

Contributor

@sdlime ticket created at #5045
I'm not sure what the best way to create a test case is - all my layers are database layers (hence a long-winded email to the dev list on possible C Unit tests).

Contributor

geographika replied Dec 3, 2014

@sdlime ticket created at #5045
I'm not sure what the best way to create a test case is - all my layers are database layers (hence a long-winded email to the dev list on possible C Unit tests).

Please sign in to comment.