rfctime.c File Reference


Detailed Description

RFC date and time conversion.

 *
 * $Log: rfctime.c,v $
 * Revision 1.1  2008/02/15 16:46:09  haraldkipp
 * First release.
 *
 *
 * 

Definition in file rfctime.c.

Go to the source code of this file.

Functions

char * TimeParseYear (CONST char *str, int *year)
 Parse string containing the year.
char * TimeParseMonth (CONST char *str, int *month)
 Parse a string for the name of a month.
char * TimeParseDmy (CONST char *str, int *mday, int *mon, int *year)
 Parse date string.
char * TimeParseHms (CONST char *str, int *hour, int *min, int *sec)
 Parse time of day string.
time_t RfcTimeParse (CONST char *str)
 Parse RFC date and time string.
char * Rfc1123TimeString (struct _tm *tm)
 Create RFC 1123 date and time string.


Function Documentation

char* TimeParseYear ( CONST char *  str,
int *  year 
)

Parse string containing the year.

Works with years including and excluding the century. If the resulting value is lower than 70, the 21st century is assumed. Values

Parameters:
str Pointer to the time string.
year Points to the variable that will receive the years since 1900.
Returns:
Pointer into the string after the parsed characters.

Definition at line 103 of file rfctime.c.

Referenced by RfcTimeParse(), and TimeParseDmy().

char* TimeParseMonth ( CONST char *  str,
int *  month 
)

Parse a string for the name of a month.

Does basic comparision only, no range checking etc. For example, if the string starts with capital letter 'D', December is assumed without further checking the rest. It will work for abbreviated as well as full names.

Parameters:
str Pointer to the time string. Must start with a capital letter followed by lower case characters.
month Points to the variable that will receive the month (0..11).
Returns:
Pointer into the string after the parsed characters.

Definition at line 129 of file rfctime.c.

Referenced by RfcTimeParse(), and TimeParseDmy().

char* TimeParseDmy ( CONST char *  str,
int *  mday,
int *  mon,
int *  year 
)

Parse date string.

Parses a string of the format day 'x' month-name 'x' year, where 'x' is any non-alphanumeric character.

Parameters:
str Pointer to the date string.
mday Points to the variable that will receive the day (1..31).
mon Points to the variable that will receive the month (0..11).
year Points to the variable that will receive the years since 1900.
Returns:
Pointer into the string after the parsed characters.

Definition at line 204 of file rfctime.c.

References TimeParseMonth(), and TimeParseYear().

Referenced by RfcTimeParse().

char* TimeParseHms ( CONST char *  str,
int *  hour,
int *  min,
int *  sec 
)

Parse time of day string.

Parses a string of the format hour ':' minute ':' second.

Parameters:
str Pointer to the time string.
hour Points to the variable that will receive the hour (0..23).
min Points to the variable that will receive the minute (0..59).
sec Points to the variable that will receive the second (0..59).
Returns:
Pointer into the string after the parsed characters.

Definition at line 231 of file rfctime.c.

Referenced by RfcTimeParse().

time_t RfcTimeParse ( CONST char *  str  ) 

Parse RFC date and time string.

This routine accepts RFC 850, RFC 1123 and asctime time formats.

Parameters:
str Pointer to the date and time string.
Returns:
Number of seconds since epoch or -1 in case of any error.

Definition at line 258 of file rfctime.c.

References _mkgmtime(), mktime(), strcmp(), TimeParseDmy(), TimeParseHms(), TimeParseMonth(), TimeParseYear(), _tm::tm_hour, _tm::tm_mday, _tm::tm_min, _tm::tm_mon, _tm::tm_sec, and _tm::tm_year.

Referenced by NutHttpProcessRequest().

char* Rfc1123TimeString ( struct _tm tm  ) 

Create RFC 1123 date and time string.

Parameters:
tm Pointer to the date and time structure.
Returns:
Pointer to a static buffer containing the string.

Definition at line 303 of file rfctime.c.

References sprintf, _tm::tm_hour, _tm::tm_mday, _tm::tm_min, _tm::tm_mon, _tm::tm_sec, _tm::tm_wday, and _tm::tm_year.

Referenced by NutHttpSendHeaderTop().


© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/