GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
incr1.c File Reference
#include <grass/datetime.h>
Include dependency graph for incr1.c:

Go to the source code of this file.

Functions

int datetime_increment (DateTime *src, DateTime *incr)
 This function changes the 'src' date/time data based on the 'incr' The type (mode/from/to) of the 'src' can be anything. The mode of the 'incr' must be RELATIVE, and the type (mode/from/to) for 'incr' must be a valid increment for 'src'. See datetime_is_valid_increment(), datetime_check_increment() Returns: 0: OK -1: 'incr' is invalid increment for 'src' For src.mode ABSOLUTE,. More...
 

Function Documentation

◆ datetime_increment()

int datetime_increment ( DateTime src,
DateTime incr 
)

This function changes the 'src' date/time data based on the 'incr' The type (mode/from/to) of the 'src' can be anything. The mode of the 'incr' must be RELATIVE, and the type (mode/from/to) for 'incr' must be a valid increment for 'src'. See datetime_is_valid_increment(), datetime_check_increment() Returns: 0: OK -1: 'incr' is invalid increment for 'src' For src.mode ABSOLUTE,.

  • positive 'incr' moves into the future,
  • negative 'incr' moves into the past.
  • BC implies the year is negative, but all else is positive. Also, year==0 is illegal: adding 1 year to 1[bc] gives 1[ad]

The 'fracsec' in 'src' is preserved. The 'from/to' of the 'src' is preserved. A timezone in 'src' is allowed - it's presence is ignored. NOTE: There is no datetime_decrement() To decrement, set the 'incr' negative.

Parameters
src
incr
Returns
int

Definition at line 68 of file incr1.c.

References datetime_change_from_to(), datetime_copy(), DATETIME_DAY, datetime_error_code(), datetime_in_interval_day_second(), datetime_is_valid_increment(), DATETIME_RELATIVE, DATETIME_YEAR, DateTime::from, DateTime::mode, DateTime::positive, src, and DateTime::to.

Referenced by datetime_change_timezone().