Changeset 11e78d5 for message.c


Ignore:
Timestamp:
Jul 22, 2011, 7:20:26 PM (13 years ago)
Author:
Jason Gross <jgross@mit.edu>
Children:
85bb19b
Parents:
f661cee
git-author:
Jason Gross <jgross@mit.edu> (07/22/11 10:43:43)
git-committer:
Jason Gross <jgross@mit.edu> (07/22/11 19:20:26)
Message:
Show the time zone in :info; replace ctime with strftime

This fixes trac-#146.

The new function owl_util_time_to_timestr takes a const struct tm *
instead of a const time_t because, although we pass around time_t for
just about everything else, this lets the caller decide whether to use
localtime or gmtime (UTC).

Note: I'm not sure that "%c" (which is locale-dependent) will always
include the time zone.  If not, or if we want a bit more consistency, we
can switch to something like "%a %b %d %H:%M:%S %Y %Z" (like "Fri Jul 22
15:39:45 2011 EDT") or "%a %b %d, %Y %h:%M:%S %p %Z" (like "Fri Jul 22,
2011 03:39:45 PM 2011 EDT") or something.  On linerva, "%c" seems to be
equivalent to "%a %d %b %Y %h:%M:%S %p %Z" (like "Fri 22 Jul 2011
03:39:45 PM EDT").
File:
1 edited

Legend:

Unmodified
Added
Removed
  • message.c

    r6500907 r11e78d5  
    4646 
    4747  /* save the time */
    48   m->time=time(NULL);
    49   m->timestr=g_strdup(ctime(&(m->time)));
    50   m->timestr[strlen(m->timestr)-1]='\0';
     48  m->time = time(NULL);
     49  m->timestr = owl_util_time_to_timestr(localtime(&m->time));
    5150
    5251  m->fmtext = NULL;
     
    796795  /* save the time, we need to nuke the string saved by message_init */
    797796  if (m->timestr) g_free(m->timestr);
    798   m->time=n->z_time.tv_sec;
    799   m->timestr=g_strdup(ctime(&(m->time)));
    800   m->timestr[strlen(m->timestr)-1]='\0';
     797  m->time = n->z_time.tv_sec;
     798  m->timestr = owl_util_time_to_timestr(localtime(&m->time));
    801799
    802800  /* set other info */
Note: See TracChangeset for help on using the changeset viewer.