Changeset 1778 for trunk/gsdl/lib


Ignore:
Timestamp:
2000-12-08T17:00:35+13:00 (23 years ago)
Author:
sjboddie
Message:

Implemented the new MailServer, LogEvents, EmailEvents and EmailUserEvents
configuration options.

Location:
trunk/gsdl/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/lib/gsdltimes.cpp

    r1310 r1778  
    2626#include "gsdltimes.h"
    2727
    28 
     28// returns a string of the form "YYYY/MM/DD hh:mm:ss" (expressed in
     29// Coordinated Universal Time (UTC))
    2930// returns "" if an error occurs
    3031text_t time2text (time_t time) {
     
    6364}
    6465
     66// takes a string like that returned by time2text and returns corresponding time_t
    6567// returns -1 if an error occurs
    6668time_t text2time (const text_t &timestr) {
     
    114116  return mktime (&timetm);
    115117}
     118
     119// returns current date and time formatted like "Thu Dec 7 23:43:38 2000"
     120// if ltime is true return value will be expressed in local time, otherwise
     121// it'll be Coordinated Universal Time (UTC)
     122// returns "" if an error occurs
     123text_t get_date (bool ltime) {
     124
     125  char *timestr;
     126  tm *tm_ptr = NULL;
     127  time_t t = time(NULL);
     128  if (ltime) tm_ptr = localtime (&t);
     129  else tm_ptr = gmtime (&t);
     130  if (tm_ptr == NULL) return "";
     131
     132  strftime (timestr, 128, "%a %b %e %T %Y", tm_ptr);
     133  text_t ret = timestr;
     134  return ret;
     135}
  • trunk/gsdl/lib/gsdltimes.h

    r1310 r1778  
    3939time_t text2time (const text_t &timestr);
    4040
     41
     42// returns formatted date in local or UTC time
     43// returns "" if an error occurs
     44text_t get_date (bool ltime);
     45
    4146#endif
Note: See TracChangeset for help on using the changeset viewer.