GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-c1f55e303d
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.


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.

Joel Jones (CERL/UIUC), Radim Blazek
Doxygenized by Martin Landa <landa.martin> (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
bufinput string buffer
sqltypeSQL data type
[out]valuepointer to dbValue to be set

Definition at line 196 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.

valuepointer to dbValue
sqltypeSQL data type
[out]stringpointer to dbString
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().