FATODATE C-3

NAME

fatodate - convert ASCII to date value

SYNOPSIS

#include <cbase/dtypes.h>

int fatodate (sptr, format, d, size)

char *sptr;

char *format;

DATE *d;

int size;

DESCRIPTION

Fatodate converts a string pointed to by sptr to a DATE value using format to control the conversion. The result of the conversion is stored in the DATE value pointed at by d. Size is the size of the DATE value.

Date values are stored internally as the number of days beginning with January 1, 1800. January 1, 1800, has a value of 1. This format allows accurate representation of birth dates, and also allows date comparison and date arithmetic.

Fatodate first tries to convert sptr using format. If this fails, two standard input formats are tried. These have the form: nn[s]nn[s]nn[nn] and dd[s]mmm[s]yy[yy]. In either form, s is an optional separator character. Any punctuation character can be used, but the same character must be used in both places.

To convert the first standard input format, nn[s]nn[s]nn[nn] the value returned by getforder(C-3) determines the order of month, day, and year values.

The second standard input format, dd[s]mmm[s]yy[yy], is used when a letter appears after two digits and an optional separator character. In this case, the abbreviated month names returned by getfamth(C-3) determine the month.

Trailing blanks or tabs are allowed, leading blanks or tabs are not.

Fatodate returns the number of characters in sptr used to convert the value.

SEE ALSO

fcountry(C-3), atodate(C-3), getforder(C-3), getfamth(C-3)

C/Base Reference Manual Chapter 13, "Formatting Data Values"

DIAGNOSTICS

If an error occurs, fatodate returns a negative number and the contents of d are undefined. The following symbolic error codes are defined in <cbase/dtypes.h>:

FTOOBIG size is not the size of a DATE value (use sizeof function)

FFORMAT format contains invalid key letters

FEDIT sptr does not match either specifier in format or the month, day, or year are invalid (such as 03/32/81)

FINCON the string sptr is inconsistent, e.g. a string of Fri, 2 Aug 1986 is inconsistent (August 2, 1986 is a Saturday)

FIFORMAT sptr does not conform to any format