Syntax
int CToD( const char *text );
Arguments
text Date text with numeric fields separated by non-digit characters. The field order comes from _SET_DATEFORMAT.
Return value
The parsed date as YYYYMMDD, or 0 if the parsed fields do not form a valid date.
Description
Convert formatted date input into the `YYYYMMDD` integer used by the date functions. The `D`, `M` and `Y` fields in the current `_SET_DATEFORMAT` determine the order in which the digit groups are read. Separate the groups, for example `"23/05/2026"` with `"dd/mm/yyyy"`.
`_SET_EPOCH` is the first year of the 100-year window used for year values below `100`. An empty string initializes an empty date. A missing day or month, an out-of-range field or an impossible calendar day gives `0`.
Example
#include "xdev-wtui.h"
#include "xdev-wtui-set.h"
#include <stdio.h>
int main( void )
{
SetC( _SET_DATEFORMAT, "mm/dd/yyyy" );
int cutoff = CToD( "10/10/1990" );
puts( 19901009 < cutoff ? "Older inventory" : "Current inventory" );
return 0;
}