Thread (6 messages) flat view 6 messages, 3 authors, 2016-06-15

Re: orthogonal cases of log --date option

From: Jay Soffian <hidden>
Date: 2016-06-15 22:46:20

On Fri, Mar 6, 2009 at 3:02 AM, Junio C Hamano [off-list ref] wrote:
Is it?  Isn't it just the matter of doing something like this?

       struct date_mode {
               enum {
               DATE_NORMAL = 0,
               DATE_RELATIVE,
               ...
               DATE_RAW
               } format;
               enum {
               DATE_ORIGINAL = 0,
               DATE_LOCAL
               /* perhaps ",DATE_GMT" later... */
               } tz_offset;
       };

       /* In revision.c::handle_revision_opt() */
       ...
       } else if (!strcmp(arg, "--date=local")) {
               revs->date_mode.format = DATE_NORMAL;
               revs->date_mode.tz_offset = DATE_LOCAL;
       } else if (!prefixcmp(arg, "--date=")) {
               revs->date_mode.format = parse_date_format(arg + 7);
       } else if (!strcmp(arg, "--tz=local")) {
               revs->date_mode.tz_offset = DATE_LOCAL;
       }
       ...

       /* In date.c::show_date() */
       ...
       const char *show_date(unsigned long time, int tz, struct date_mode *mode_)
       {
               int mode = mode_->format;

               if (mode_->tz_offset == DATE_LOCAL)
                       tz = local_tzoffset(time);

               ...
               /* and remove the existing
               if (mode == DATE_LOCAL)
                       tz = local_tzoffset(time);
                  that appears later in the code
               */
       ...

Yeah, that part is easy. I wasn't sure the best way to handle places
where a constant date_mode is used e.g.:

pp_user_info(NULL, CMIT_FMT_EMAIL, &sb, committer, DATE_RFC2822,
		     encoding);

I had started on:

static const struct date_mode date_rfc2822 = {DATE_RFC2822, DATE_ORIGINAL};
...
pp_user_info(NULL, CMIT_FMT_EMAIL, &sb, committer, &date_rfc2822,
		     encoding);

But I imagine there's maybe a better way to do that.

j.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help