GRASS 8 Programmer's Manual
8.6.0dev(2026)-1d1e47ad9d
Loading...
Searching...
No Matches
date.c
Go to the documentation of this file.
1
/*!
2
* \file lib/gis/date.c
3
*
4
* \brief GIS Library - Date functions.
5
*
6
* (C) 2001-2009 by the GRASS Development Team
7
*
8
* This program is free software under the GNU General Public License
9
* (>=v2). Read the file COPYING that comes with GRASS for details.
10
*
11
* \author Original author CERL
12
*/
13
14
#include <
time.h
>
15
#include <
grass/gis.h
>
16
17
/*!
18
* \brief Current date and time.
19
*
20
* Returns a pointer to a string which is the current date and
21
* time. The format is the same as that produced by the UNIX
22
* <tt>date</tt> command.
23
*
24
* \return pointer to a string holding date/time
25
*/
26
const
char
*
G_date
(
void
)
27
{
28
static
int
initialized;
29
static
char
*date;
30
time_t
clock;
31
struct
tm
*
local
;
32
char
*
tdate
;
33
char
*d;
34
35
if
(
G_is_initialized
(&initialized))
36
return
date;
37
38
time
(&clock);
39
40
local
=
localtime
(&clock);
41
tdate
=
asctime
(
local
);
42
for
(d =
tdate
; *d; d++)
43
if
(*d ==
'\n'
)
44
*d = 0;
45
46
date =
G_store
(
tdate
);
47
48
G_initialize_done
(&initialized);
49
50
return
date;
51
}
AMI_STREAM
Definition
ami_stream.h:153
AMI_STREAM::AMI_STREAM
AMI_STREAM()
Definition
ami_stream.h:227
G_date
const char * G_date(void)
Current date and time.
Definition
date.c:26
G_is_initialized
int G_is_initialized(int *)
Definition
counter.c:60
G_initialize_done
void G_initialize_done(int *)
Definition
counter.c:77
G_store
char * G_store(const char *)
Copy string to allocated memory.
Definition
strings.c:87
gis.h
time.h
lib
gis
date.c
Generated on Fri Apr 3 2026 06:59:53 for GRASS 8 Programmer's Manual by
1.9.8