date.c 855 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * \file date.c
  3. *
  4. * \brief GIS Library - Date functions.
  5. *
  6. * (C) 2001-2008 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 GRASS GIS Development Team
  12. *
  13. * \date 1999-2008
  14. */
  15. #include <time.h>
  16. #include <grass/gis.h>
  17. /**
  18. * \brief Current date and time.
  19. *
  20. * Returns a pointer to a string which is the current date and time. The
  21. * format is the same as that produced by the UNIX <i>date</i> command.
  22. *
  23. * \return Pointer to a string holding date/time
  24. */
  25. char *G_date(void)
  26. {
  27. time_t clock;
  28. struct tm *local;
  29. char *date;
  30. char *d;
  31. time(&clock);
  32. local = localtime(&clock);
  33. date = asctime(local);
  34. for (d = date; *d; d++)
  35. if (*d == '\n')
  36. *d = 0;
  37. return date;
  38. }