Grid Community Toolkit  6.2.1550507116
globus_strptime.h
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2006 University of Chicago
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
22 #ifndef GLOBUS_STRPTIME_H
23 #define GLOBUS_STRPTIME_H 1
24 
25 #include "globus_common_include.h"
26 
27 
28 /******************************************************************************
29 Function: globus_strptime()
30 
31 Description:
32 
33  Parse and validate a date string (pointed to by parameter 1) based on a
34  supplied format string (pointed to by parameter 2), putting the parsed and
35  validated date values in a tm struct (pointed to by parameter 3).
36  See description of the parameter "format_str" for a description of the
37  parsing and validation rules.
38 
39 Parameters:
40 
41  date_str:
42  Points to the date string that is to be parsed and validated.
43 
44  format_str:
45  Contains zero or more conversion specifications. (See description below.)
46 
47  time_ptr:
48  A pointer to a struct tm for returning the parsed and validated date data.
49 
50 Returns:
51  pointer to character
52  On successful completion:
53  pointer to the first character of buffer that was not
54  used in evaluating the format string.
55  On unsuccessful completion:
56  NULL pointer.
57 
58 
59 Format specification:
60  Each specification is composed of a '%' (percent) character followed by a
61  conversion character specifying the required conversion.
62  One or more white space characters may (optionally) precede or follow any
63  conversion specification.
64  Non-white space characters that are not part of a conversion specification
65  may be included in the format string, and must be matched exactly
66  (including case for letters) in the date_str. '%' (percent) can be
67  specified as a character to match by using "%%".
68  Multiple occurences of conversions for a given component of the date/time
69  (second, minute, hour, day, day of month, month, year, century) is
70  detected as an error.
71  White space in the date_str will terminate a numeric value, but is
72  otherwise skipped and ignored.
73  All numeric fields are taken as decimal, must begin with a digit,
74  and are matched up to a maximum number of digits (or the first
75  non-digit).
76  Note the the year returned in the tm_year field of the tm struct is
77  relative to 1900 (e.g., 58 means year 1958, -8 means year 1892).
78  Also, if the year is specified, but not the century, then values
79  50-99 are taken as 20th century, 00-49 are taken as 21st century.
80 
81  The following conversion specifications are recognized:
82  %a %A day of week (3 character abbreviation or full name)
83  Validated as Sun-Sat, not validated as correct for
84  any specified date.
85  %b %h %B month name (3 character abbreviation or full name)
86  %C century number (Up to 2 digits)
87  %d %e day of month (Up to 2 digits)
88  Validated as 1-31. If month is provided, further
89  validated as not 31 for February, April, June,
90  September, or November, nor 30 for February.
91  If year and month provided then validated as not 29
92  for February in a non-leap year.
93  %D date as %m/%d/%y
94  %H hour (0-23) (Up to 2 digits)
95  Error if %p is used.
96  %I hour (1-12) (Up to 2 digits)
97  Converted to 24 hour clock when put in struct tm.
98  Assumed AM unless %p flag is used.
99  %m month (1-12) (Up to 2 digits)
100  Returned in the tm struct as (0-11).
101  %M minute (0-59) (Up to 2 digits)
102  %n white space (White space is ignored.)
103  %p AM or PM or A.M. or P.M. (case independent)
104  (Error if %I is used.)
105  %R %H:%M
106  %S seconds (0-61) allows for 1 or 2 leap seconds
107  (Up to 2 digits)
108  %t white space (White space is ignored.)
109  %T %H:%M:%S
110  %y year within century (Up to 2 digits)
111  %Y year with century (Up to 4 digits)
112 
113  Any whitespace in format is ignored.
114  Any whitespace in buffer serves to delimit numeric fields
115  (such as second, minute, hour, day, month, year) but
116  is otherwise ignored.
117  (I.e., a run of spaces, tabs, etc. is matched by any
118  run of spaces, tabs, etc. even if the corresponding
119  characters are are not identical or the counts
120  are not the same.)
121  Characters that are not whitespace and are not preceded by '%'
122  must match exactly.
123  Allows %% as literal '%' in buffer.
124  The buffer is matched to the end of the format and no further.
125 
126 
127 ******************************************************************************/
128 
129 #ifdef __cplusplus
130 extern "C" {
131 #endif
132 
133 char*
134 globus_strptime(
135  char* date_str,
136  char* format_str,
137  struct tm* time_ptr );
138 
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif /* GLOBUS_STRPTIME_H */
Include System Headers.