GRASS GIS 7 Programmer's Manual  7.0.4(2016)-r00000
date.c
Go to the documentation of this file.
1 
14 #include <time.h>
15 #include <grass/gis.h>
16 
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 }
const char * G_date(void)
Current date and time.
Definition: date.c:26
char * G_store(const char *s)
Copy string to allocated memory.
Definition: strings.c:86
int G_is_initialized(int *p)
Definition: counter.c:59
void G_initialize_done(int *p)
Definition: counter.c:76
struct tm * localtime()