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