GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
datetime/type.c File Reference
#include <grass/datetime.h>
Include dependency graph for datetime/type.c:

Go to the source code of this file.

Functions

int datetime_set_type (DateTime *dt, int mode, int from, int to, int fracsec)
 
int datetime_get_type (const DateTime *dt, int *mode, int *from, int *to, int *fracsec)
 
int datetime_is_valid_type (const DateTime *dt)
 Returns: 1 if datetime_check_type() returns 0 0 if not. More...
 
int datetime_check_type (const DateTime *dt)
 checks the mode/from/to/fracsec in dt. Returns: More...
 
int datetime_in_interval_year_month (int x)
 
int datetime_in_interval_day_second (int x)
 
int datetime_is_absolute (const DateTime *dt)
 Returns: 1 if dt.mode is absolute 0 if not (even if dt.mode is not defined) More...
 
int datetime_is_relative (const DateTime *dt)
 Returns: 1 if dt.mode is relative 0 if not (even if dt.mode is not defined) More...
 

Function Documentation

◆ datetime_check_type()

int datetime_check_type ( const DateTime dt)

checks the mode/from/to/fracsec in dt. Returns:

  • 0: OK
  • -1: mode is invalid - not one of {ABSOLUTE,RELATIVE}
  • -2: from is invalid - not one of {YEAR,MONTH,DAY,HOUR,MINUTE,SECOND}
  • -3: to is invalid - not one of {YEAR,MONTH,DAY,HOUR,MINUTE,SECOND}
  • -4: from/to are reversed (from>to is illegal)
  • -5: invalid from/to combination for RELATIVE mode: from in {YEAR,MONTH} but to is not, or from in {DAY,HOUR,MINUTE,SECOND} but to is not
  • -6: from is invalid for ABSOLUTE mode (from != YEAR is illegal)
  • -7: fracsec is negative (only if to==SECOND)
Parameters
dt
Returns
int

Definition at line 116 of file datetime/type.c.

References DATETIME_ABSOLUTE, datetime_error(), datetime_in_interval_day_second(), datetime_in_interval_year_month(), datetime_is_between(), DATETIME_RELATIVE, DATETIME_SECOND, DATETIME_YEAR, DateTime::fracsec, DateTime::from, DateTime::mode, and DateTime::to.

Referenced by datetime_is_valid_type().

◆ datetime_get_type()

int datetime_get_type ( const DateTime dt,
int *  mode,
int *  from,
int *  to,
int *  fracsec 
)

Definition at line 58 of file datetime/type.c.

◆ datetime_in_interval_day_second()

int datetime_in_interval_day_second ( int  x)

Definition at line 156 of file datetime/type.c.

References DATETIME_DAY, datetime_is_between(), and DATETIME_SECOND.

Referenced by datetime_check_type().

◆ datetime_in_interval_year_month()

int datetime_in_interval_year_month ( int  x)

Definition at line 151 of file datetime/type.c.

References datetime_is_between(), DATETIME_MONTH, and DATETIME_YEAR.

Referenced by datetime_check_type().

◆ datetime_is_absolute()

int datetime_is_absolute ( const DateTime dt)

Returns: 1 if dt.mode is absolute 0 if not (even if dt.mode is not defined)

Parameters
dt
Returns
int

Definition at line 173 of file datetime/type.c.

References DATETIME_ABSOLUTE, and DateTime::mode.

Referenced by datetime_check_timezone(), datetime_format(), datetime_set_month(), and datetime_set_year().

◆ datetime_is_relative()

int datetime_is_relative ( const DateTime dt)

Returns: 1 if dt.mode is relative 0 if not (even if dt.mode is not defined)

Parameters
dt
Returns
int

Definition at line 190 of file datetime/type.c.

References DATETIME_RELATIVE, and DateTime::mode.

◆ datetime_is_valid_type()

int datetime_is_valid_type ( const DateTime dt)

Returns: 1 if datetime_check_type() returns 0 0 if not.

Parameters
dt
Returns
int

Definition at line 80 of file datetime/type.c.

References datetime_check_type().

Referenced by datetime_format().

◆ datetime_set_type()

int datetime_set_type ( DateTime dt,
int  mode,
int  from,
int  to,
int  fracsec 
)
  • This routine must be called can be made with other datetime functions.
  • initialize all the elements in dt.
  • Set all values to zero except: tz (set to illegal value - 99*24) positive (set to 1 for positive)
  • Set the type info in dt: mode, from, to, fracsec
  • validate the mode/from/to/fracsec (according to the rules for the mode)
  • return the return value from datetime_check_type(dt)
Parameters
mode
from
to
fracsec
Returns
int

Definition at line 37 of file datetime/type.c.

Referenced by datetime_change_timezone(), datetime_get_local_time(), and datetime_get_local_timezone().