GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
values.c File Reference
#include <grass/datetime.h>
Include dependency graph for values.c:

Go to the source code of this file.

Functions

int datetime_check_year (const DateTime *dt, int year)
 Returns: 0 is legal year for dt -1 illegal year for this dt -2 dt has no year component. More...
 
int datetime_check_month (const DateTime *dt, int month)
 Returns: 0 is legal month for dt -1 illegal month for this dt -2 dt has no month component. More...
 
int datetime_check_day (const DateTime *dt, int day)
 Returns: 0 is legal day for dt -1 illegal day for this dt -2 dt has no day component
Note: if dt.mode is ABSOLUTE, then dt.year and dt.month must also be legal, since the 'day' must be a legal value for the dt.year/dt.month. More...
 
int datetime_check_hour (const DateTime *dt, int hour)
 returns: 0 on success -1 if 'dt' has an invalid hour -2 if 'dt' has no hour More...
 
int datetime_check_minute (const DateTime *dt, int minute)
 returns: 0 on success -1 if 'dt' has an invalid minute -2 if 'dt' has no minute More...
 
int datetime_check_second (const DateTime *dt, double second)
 returns: 0 on success -1 if 'dt' has an invalid second -2 if 'dt' has no second More...
 
int datetime_check_fracsec (const DateTime *dt, int fracsec)
 returns: 0 on success -1 if 'dt' has an invalid fracsec -2 if 'dt' has no fracsec More...
 
int datetime_get_year (const DateTime *dt, int *year)
 returns 0 on success or negative value on error More...
 
int datetime_set_year (DateTime *dt, int year)
 if dt.mode = ABSOLUTE, this also sets dt.day = 0 More...
 
int datetime_get_month (const DateTime *dt, int *month)
 returns 0 on success or negative value on error More...
 
int datetime_set_month (DateTime *dt, int month)
 if dt.mode = ABSOLUTE, this also sets dt.day = 0 More...
 
int datetime_get_day (const DateTime *dt, int *day)
 returns 0 on success or negative value on error More...
 
int datetime_set_day (DateTime *dt, int day)
 if dt.mode = ABSOLUTE, then the dt.year, dt.month: More...
 
int datetime_get_hour (const DateTime *dt, int *hour)
 returns 0 on success or negative value on error More...
 
int datetime_set_hour (DateTime *dt, int hour)
 returns 0 on success or negative value on error More...
 
int datetime_get_minute (const DateTime *dt, int *minute)
 returns 0 on success or negative value on error More...
 
int datetime_set_minute (DateTime *dt, int minute)
 returns 0 on success or negative value on error More...
 
int datetime_get_second (const DateTime *dt, double *second)
 returns 0 on success or negative value on error More...
 
int datetime_set_second (DateTime *dt, double second)
 returns 0 on success or negative value on error More...
 
int datetime_get_fracsec (const DateTime *dt, int *fracsec)
 returns 0 on success or negative value on error More...
 
int datetime_set_fracsec (DateTime *dt, int fracsec)
 returns 0 on success or negative value on error More...
 

Function Documentation

◆ datetime_check_day()

int datetime_check_day ( const DateTime dt,
int  day 
)

Returns: 0 is legal day for dt -1 illegal day for this dt -2 dt has no day component
Note: if dt.mode is ABSOLUTE, then dt.year and dt.month must also be legal, since the 'day' must be a legal value for the dt.year/dt.month.

Parameters
dt
day
Returns
int

Definition at line 91 of file values.c.

Referenced by datetime_get_day(), and datetime_set_day().

◆ datetime_check_fracsec()

int datetime_check_fracsec ( const DateTime dt,
int  fracsec 
)

returns: 0 on success -1 if 'dt' has an invalid fracsec -2 if 'dt' has no fracsec

Parameters
dt
fracsec
Returns
int

Definition at line 207 of file values.c.

Referenced by datetime_get_fracsec(), and datetime_set_fracsec().

◆ datetime_check_hour()

int datetime_check_hour ( const DateTime dt,
int  hour 
)

returns: 0 on success -1 if 'dt' has an invalid hour -2 if 'dt' has no hour

Parameters
dt
hour
Returns
int

Definition at line 129 of file values.c.

Referenced by datetime_get_hour(), and datetime_set_hour().

◆ datetime_check_minute()

int datetime_check_minute ( const DateTime dt,
int  minute 
)

returns: 0 on success -1 if 'dt' has an invalid minute -2 if 'dt' has no minute

Parameters
dt
minute
Returns
int

Definition at line 155 of file values.c.

Referenced by datetime_get_minute(), and datetime_set_minute().

◆ datetime_check_month()

int datetime_check_month ( const DateTime dt,
int  month 
)

Returns: 0 is legal month for dt -1 illegal month for this dt -2 dt has no month component.

Parameters
dt
month
Returns
int

Definition at line 55 of file values.c.

Referenced by datetime_get_month(), and datetime_set_month().

◆ datetime_check_second()

int datetime_check_second ( const DateTime dt,
double  second 
)

returns: 0 on success -1 if 'dt' has an invalid second -2 if 'dt' has no second

Parameters
dt
second
Returns
int

Definition at line 181 of file values.c.

◆ datetime_check_year()

int datetime_check_year ( const DateTime dt,
int  year 
)

Returns: 0 is legal year for dt -1 illegal year for this dt -2 dt has no year component.

Parameters
dt
year
Returns
int

Definition at line 29 of file values.c.

Referenced by datetime_get_year(), and datetime_set_year().

◆ datetime_get_day()

int datetime_get_day ( const DateTime dt,
int *  day 
)

returns 0 on success or negative value on error

Parameters
dt
day
Returns
int

Definition at line 325 of file values.c.

References datetime_check_day(), and DateTime::day.

Referenced by datetime_format().

◆ datetime_get_fracsec()

int datetime_get_fracsec ( const DateTime dt,
int *  fracsec 
)

returns 0 on success or negative value on error

Parameters
dt
fracsec
Returns
int

Definition at line 508 of file values.c.

References datetime_check_fracsec(), and DateTime::fracsec.

◆ datetime_get_hour()

int datetime_get_hour ( const DateTime dt,
int *  hour 
)

returns 0 on success or negative value on error

Parameters
dt
hour
Returns
int

Definition at line 376 of file values.c.

References datetime_check_hour(), and DateTime::hour.

◆ datetime_get_minute()

int datetime_get_minute ( const DateTime dt,
int *  minute 
)

returns 0 on success or negative value on error

Parameters
dt
minute
Returns
int

Definition at line 420 of file values.c.

References datetime_check_minute(), and DateTime::minute.

◆ datetime_get_month()

int datetime_get_month ( const DateTime dt,
int *  month 
)

returns 0 on success or negative value on error

Parameters
dt
month
Returns
int

Definition at line 276 of file values.c.

References datetime_check_month(), and DateTime::month.

Referenced by datetime_format().

◆ datetime_get_second()

int datetime_get_second ( const DateTime dt,
double *  second 
)

returns 0 on success or negative value on error

Parameters
dt
second
Returns
int

Definition at line 464 of file values.c.

◆ datetime_get_year()

int datetime_get_year ( const DateTime dt,
int *  year 
)

returns 0 on success or negative value on error

Parameters
dt
year
Returns
int

Definition at line 227 of file values.c.

References datetime_check_year(), and DateTime::year.

◆ datetime_set_day()

int datetime_set_day ( DateTime dt,
int  day 
)

if dt.mode = ABSOLUTE, then the dt.year, dt.month:

if (day > <b>datetime_days_in_month</b> (dt.year, dt.month))
{error}

This implies that year/month must be set for ABSOLUTE datetimes.

Returns 0 on success or negative value on error

Parameters
dt
day
Returns
int

Definition at line 354 of file values.c.

References datetime_check_day(), and DateTime::day.

Referenced by datetime_get_local_time(), and datetime_get_local_timezone().

◆ datetime_set_fracsec()

int datetime_set_fracsec ( DateTime dt,
int  fracsec 
)

returns 0 on success or negative value on error

Parameters
dt
fracsec
Returns
int

Definition at line 530 of file values.c.

References datetime_check_fracsec(), and DateTime::fracsec.

◆ datetime_set_hour()

int datetime_set_hour ( DateTime dt,
int  hour 
)

returns 0 on success or negative value on error

Parameters
dt
hour
Returns
int

Definition at line 398 of file values.c.

References datetime_check_hour(), and DateTime::hour.

Referenced by datetime_get_local_time(), and datetime_get_local_timezone().

◆ datetime_set_minute()

int datetime_set_minute ( DateTime dt,
int  minute 
)

returns 0 on success or negative value on error

Parameters
dt
minute
Returns
int

Definition at line 442 of file values.c.

References datetime_check_minute(), and DateTime::minute.

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

◆ datetime_set_month()

int datetime_set_month ( DateTime dt,
int  month 
)

if dt.mode = ABSOLUTE, this also sets dt.day = 0

returns 0 on success or negative value on error

Parameters
dt
month
Returns
int

Definition at line 300 of file values.c.

References datetime_check_month(), datetime_is_absolute(), DateTime::day, and DateTime::month.

Referenced by datetime_get_local_time(), and datetime_get_local_timezone().

◆ datetime_set_second()

int datetime_set_second ( DateTime dt,
double  second 
)

returns 0 on success or negative value on error

Parameters
dt
second
Returns
int

Definition at line 486 of file values.c.

Referenced by datetime_get_local_time(), and datetime_get_local_timezone().

◆ datetime_set_year()

int datetime_set_year ( DateTime dt,
int  year 
)

if dt.mode = ABSOLUTE, this also sets dt.day = 0

returns 0 on success or negative value on error

Parameters
dt
year
Returns
int

Definition at line 251 of file values.c.

References datetime_check_year(), datetime_is_absolute(), DateTime::day, and DateTime::year.

Referenced by datetime_get_local_time(), and datetime_get_local_timezone().