General Terminal

GtDateAdd

Add days to a date

Syntax

Signature
int GtDateAdd( int date, int days );

Arguments

date is a date encoded as YYYYMMDD.

days is the number of calendar days to add. Use a negative value to move backward.

Return value

The resulting YYYYMMDD date, or 0 for a nonpositive input date or a result outside years 1 through 9999.

Description

Adds days across month and year boundaries. For example, adding one day to February 28 in a leap year gives February 29.

Example

gtdateadd.c
#include "xdev-wtui.h"

#include <stdio.h>

int main( void )
{
   int next = GtDateAdd( 20240228, 1 );

   puts( DToS( next ) );

   return 0;
}

Output

20240229

See also