|
GRASS 8 Programmer's Manual 8.6.0dev(2026)-1d1e47ad9d
|
GIS Library - Timestamp management. More...
#include <stdio.h>#include <string.h>#include <unistd.h>#include <grass/gis.h>#include <grass/vect/dig_defines.h>#include <grass/glocale.h>
Go to the source code of this file.
Macros | |
| #define | RAST_MISC "cell_misc" |
| #define | GRID3 "grid3" |
GIS Library - Timestamp management.
Provides DateTime functions for timestamp management.
The timestamp values must use the format as described in the GRASS datetime library. The source tree for this library should have a description of the format. For convenience, the formats as of Feb, 1996 are reproduced here:
There are two types of datetime values: absolute and relative. Absolute values specify exact dates and/or times. Relative values specify a span of time. Some examples will help clarify:
Absolute
The general format for absolute values is:
day month year [bc] hour:minute:seconds timezone
day is 1-31 month is jan,feb,...,dec year is 4 digit year [bc] if present, indicates dates is BC hour is 0-23 (24 hour clock) minute is 0-59 second is 0-59.9999 (fractions of second allowed) timezone is +hhmm or -hhmm (eg, -0600)
parts can be missing
1994 [bc] Jan 1994 [bc] 15 jan 1000 [bc] 15 jan 1994 [bc] 10 [+0000] 15 jan 1994 [bc] 10:00 [+0100] 15 jan 1994 [bc] 10:00:23.34 [-0500]
Relative
There are two types of relative datetime values, year- month and day-second.
The formats are:
[-] # years # months [-] # days # hours # minutes # seconds
The words years, months, days, hours, minutes, seconds are literal words, and the # are the numeric values.
Examples:
2 years 5 months 2 years 5 months 100 days 15 hours 25 minutes 35.34 seconds 100 days 25 minutes 1000 hours 35.34 seconds
The following are illegal because it mixes year-month and day-second (because the number of days in a month or in a year vary):
3 months 15 days 3 years 10 days
(C) 2001-2009 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.
Definition in file timestamp.c.
| #define GRID3 "grid3" |
Definition at line 88 of file timestamp.c.
| #define RAST_MISC "cell_misc" |
Definition at line 87 of file timestamp.c.
Read timestamp.
| fd | file descriptor | |
| [out] | ts | pointer to TimeStamp structure |
Definition at line 136 of file timestamp.c.
References G_scan_timestamp().
Referenced by G_read_vector_timestamp().
Create text string from TimeStamp structure.
Fills string *buf with info from TimeStamp structure *ts in a pretty way. The TimeStamp struct is defined in gis.h and populated with e.g. G_read_raster_timestamp().
| ts | TimeStamp structure containing time info |
| buf | string to receive formatted timestamp |
Definition at line 183 of file timestamp.c.
References TimeStamp::count, datetime_format(), TimeStamp::dt, and strcpy.
Referenced by G_write_timestamp().
Copy TimeStamp into [two] Datetimes structs.
Use to copy the TimeStamp information into Datetimes, as the members of struct TimeStamp shouldn't be accessed directly.
| ts | source TimeStamp structure | |
| [out] | dt1 | first DateTime struct to be filled |
| [out] | dt2 | second DateTime struct to be filled |
| [out] | count | return code |
Definition at line 260 of file timestamp.c.
References TimeStamp::count, count, datetime_copy(), and TimeStamp::dt.
Check if timestamp for 3D raster map exists.
| name | map name |
| mapset | mapset name |
Definition at line 576 of file timestamp.c.
References G_find_file2_misc(), GRID3, and name.
Check if timestamp for raster map exists.
| name | map name |
| mapset | mapset name |
Definition at line 356 of file timestamp.c.
References G_find_file2_misc(), name, and RAST_MISC.
Check if timestamp for vector map exists.
| name | map name |
| layer | The layer names, in case of NULL, layer one is assumed |
| mapset | mapset name |
Definition at line 422 of file timestamp.c.
References access, G_debug(), G_file_name(), GNAME_MAX, GPATH_MAX, GV_DIRECTORY, GV_TIMESTAMP_ELEMENT, name, NULL, and R_OK.
Referenced by G_read_vector_timestamp().
Initialize timestamp structure.
| ts | pointer to TimeStamp structure |
Definition at line 95 of file timestamp.c.
References TimeStamp::count.
Referenced by G_scan_timestamp().
Read timestamp from 3D raster map.
| name | map name | |
| mapset | mapset name | |
| [out] | ts | TimeStamp struct to populate |
Definition at line 594 of file timestamp.c.
Read timestamp from raster map.
| name | map name | |
| mapset | mapset the map lives in | |
| [out] | ts | TimeStamp struct to populate |
Definition at line 374 of file timestamp.c.
| int G_read_vector_timestamp | ( | const char * | name, |
| const char * | layer, | ||
| const char * | mapset, | ||
| struct TimeStamp * | ts | ||
| ) |
Read timestamp from vector map.
| name | map name | |
| layer | The layer names, in case of NULL, layer one is assumed | |
| mapset | mapset name | |
| [out] | ts | TimeStamp struct to populate |
Definition at line 458 of file timestamp.c.
References _, G__read_timestamp(), G_debug(), G_fopen_old(), G_has_vector_timestamp(), G_mapset(), G_warning(), GNAME_MAX, GPATH_MAX, GV_DIRECTORY, GV_TIMESTAMP_ELEMENT, name, and NULL.
Remove timestamp from 3D raster map.
Only timestamp files in current mapset can be removed.
| name | map name |
Definition at line 627 of file timestamp.c.
References G_remove_misc(), GRID3, and name.
Remove timestamp from raster map.
Only timestamp files in current mapset can be removed.
| name | map name |
Definition at line 407 of file timestamp.c.
References G_remove_misc(), name, and RAST_MISC.
Remove timestamp from vector map.
Only timestamp files in current mapset can be removed.
| name | map name |
| layer | The layer names, in case of NULL, layer one is assumed |
Definition at line 553 of file timestamp.c.
References G_remove(), GNAME_MAX, GPATH_MAX, GV_DIRECTORY, GV_TIMESTAMP_ELEMENT, and name.
Fill a TimeStamp structure from a datetime string.
Populate a TimeStamp structure (defined in gis.h) from a text string. Checks to make sure text string is in valid GRASS datetime format.
| ts | TimeStamp structure to be populated |
| buf | string containing formatted time info |
Definition at line 217 of file timestamp.c.
References datetime_scan(), G_init_timestamp(), G_set_timestamp(), G_set_timestamp_range(), and t.
Referenced by G__read_timestamp().
Set timestamp (single)
Definition at line 106 of file timestamp.c.
References TimeStamp::count, datetime_copy(), and TimeStamp::dt.
Referenced by G_scan_timestamp().
Set timestamp (range)
Definition at line 118 of file timestamp.c.
References TimeStamp::count, datetime_copy(), and TimeStamp::dt.
Referenced by G_scan_timestamp().
Write timestamp of 3D raster map.
| name | map name | |
| [out] | ts | TimeStamp struct to populate |
Definition at line 611 of file timestamp.c.
Write timestamp of raster map.
| name | map name | |
| [out] | ts | TimeStamp struct to populate |
Definition at line 391 of file timestamp.c.
References name, and RAST_MISC.
Referenced by IL_output_2d().
Output TimeStamp structure to a file as a formatted string.
A handy fd might be "stdout".
| [in,out] | fd | file descriptor |
| ts | pointer to TimeStamp structure |
Definition at line 160 of file timestamp.c.
References G_format_timestamp().
Referenced by G_write_vector_timestamp().
Write timestamp of vector map.
| name | map name | |
| layer | The layer names, in case of NULL, layer one is assumed | |
| [out] | ts | TimeStamp struct to populate |
Definition at line 507 of file timestamp.c.
References _, G_debug(), G_fopen_new(), G_mapset(), G_warning(), G_write_timestamp(), GNAME_MAX, GPATH_MAX, GV_DIRECTORY, GV_TIMESTAMP_ELEMENT, name, and NULL.