GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
datetime.c File Reference

DBMI Library (base) - datetime conversions. More...

#include <stdio.h>
#include <string.h>
#include <grass/dbmi.h>
Include dependency graph for datetime.c:

Go to the source code of this file.

Functions

int db_convert_value_datetime_into_string (dbValue *value, int sqltype, dbString *string)
 Convert datetime value into string. More...
 
int db_convert_Cstring_to_value_datetime (const char *buf, int sqltype, dbValue *value)
 Convert datetime string to value. More...
 

Detailed Description

DBMI Library (base) - datetime conversions.

(C) 1999-2009, 2011 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Joel Jones (CERL/UIUC), Radim Blazek
Doxygenized by Martin Landa <landa.martin gmail.com> (2011)

Definition in file datetime.c.

Function Documentation

◆ db_convert_Cstring_to_value_datetime()

int db_convert_Cstring_to_value_datetime ( const char *  buf,
int  sqltype,
dbValue value 
)

Convert datetime string to value.

The format of buf must be as follows

  • buf == "CURRENT" in a case-insignificant fashion value is marked as current
  • sqltype == DB_SQL_TYPE_DATE "year*month*day"
  • sqltype == DB_SQL_TYPE_TIME "hour*minute*second"
  • sqltype == DB_SQL_TYPE_TIMESTAMP "year*month*day hour*minute*second"
  • otherwise the to and from markings in sqltype are used, where "*" represents any non-whitespace character
Parameters
bufinput string buffer
sqltypeSQL data type
[out]valuepointer to dbValue to be set
Returns
DB_OK

Definition at line 197 of file datetime.c.

References DB_DAY, DB_FRACTION, DB_HOUR, db_interval_range(), DB_MINUTE, DB_MONTH, db_nocase_compare(), DB_OK, DB_SECOND, db_set_value_datetime_current(), db_set_value_day(), db_set_value_hour(), db_set_value_minute(), db_set_value_month(), db_set_value_seconds(), db_set_value_year(), DB_SQL_TYPE_DATE, DB_SQL_TYPE_TIME, DB_SQL_TYPE_TIMESTAMP, and DB_YEAR.

◆ db_convert_value_datetime_into_string()

int db_convert_value_datetime_into_string ( dbValue value,
int  sqltype,
dbString string 
)

Convert datetime value into string.

Parameters
valuepointer to dbValue
sqltypeSQL data type
[out]stringpointer to dbString
Returns
DB_OK on success

Definition at line 31 of file datetime.c.

References db_get_value_day(), db_get_value_hour(), db_get_value_minute(), db_get_value_month(), db_get_value_seconds(), db_get_value_year(), db_interval_range(), DB_MONTH, db_set_string(), db_test_value_datetime_current(), and DB_YEAR.

Referenced by db_convert_value_to_string().