Back to index

citadel  8.12
Enumerations | Functions
genstamp.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  { DATESTRING_RFC822, DATESTRING_IMAP }

Functions

void datestring (char *buf, size_t n, time_t xtime, int which_format)

Enumeration Type Documentation

anonymous enum
Enumerator:
DATESTRING_RFC822 
DATESTRING_IMAP 

Definition at line 4 of file genstamp.h.


Function Documentation

void datestring ( char *  buf,
size_t  n,
time_t  xtime,
int  which_format 
)

Definition at line 39 of file genstamp.c.

                                                                     {
       struct tm t;

       long offset;
       char offsign;

       localtime_r(&xtime, &t);

       /* Convert "seconds west of GMT" to "hours/minutes offset" */
#ifdef HAVE_STRUCT_TM_TM_GMTOFF
       offset = t.tm_gmtoff;
#else
       offset = timezone;
#endif
       if (offset > 0) {
              offsign = '+';
       }
       else {
              offset = 0L - offset;
              offsign = '-';
       }
       offset = ( (offset / 3600) * 100 ) + ( offset % 60 );

       switch(which_format) {

              case DATESTRING_RFC822:
                     snprintf(buf, n, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
                            weekdays[t.tm_wday],
                            t.tm_mday,
                            months[t.tm_mon],
                            t.tm_year + 1900,
                            t.tm_hour,
                            t.tm_min,
                            t.tm_sec,
                            offsign, offset
                            );
              break;

              case DATESTRING_IMAP:
                     snprintf(buf, n, "%02d-%s-%04d %02d:%02d:%02d %c%04ld",
                            t.tm_mday,
                            months[t.tm_mon],
                            t.tm_year + 1900,
                            t.tm_hour,
                            t.tm_min,
                            t.tm_sec,
                            offsign, offset
                            );
              break;

       }
}

Here is the call graph for this function:

Here is the caller graph for this function: