GRASS 8 Programmer's Manual
8.6.0dev(2026)-1878fdfec5
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
* SPDX-FileCopyrightText: 2001-2009 GRASS Development Team
7
* SPDX-License-Identifier: GPL-2.0-or-later
8
*
9
* \author Original author CERL
10
*/
11
12
#include <
time.h
>
13
#include <
grass/gis.h
>
14
15
/*!
16
* \brief Current date and time.
17
*
18
* Returns a pointer to a string which is the current date and
19
* time. The format is the same as that produced by the UNIX
20
* <tt>date</tt> command.
21
*
22
* \return pointer to a string holding date/time
23
*/
24
const
char
*
G_date
(
void
)
25
{
26
static
int
initialized;
27
static
char
*date;
28
time_t
clock;
29
struct
tm
*
local
;
30
char
*
tdate
;
31
char
*d;
32
33
if
(
G_is_initialized
(&initialized))
34
return
date;
35
36
time
(&clock);
37
38
local
=
localtime
(&clock);
39
tdate
=
asctime
(
local
);
40
for
(d =
tdate
; *d; d++)
41
if
(*d ==
'\n'
)
42
*d = 0;
43
44
date =
G_store
(
tdate
);
45
46
G_initialize_done
(&initialized);
47
48
return
date;
49
}
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:24
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:85
gis.h
time.h
lib
gis
date.c
Generated on Wed Sep 9 2026 06:57:42 for GRASS 8 Programmer's Manual by
1.9.8