git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: orthogonal cases of log --date option

From
Jay Soffian <jaysoffian@gmail.com>
Date
Mar 6, 2009, 08:31 UTC
Message-ID
<76718490903060031u2bbc5c08k6a635dcdb1c8bc32@mail.gmail.com>
In-Reply-To
<7v1vtbw03h.fsf@gitster.siamese.dyndns.org>
On Fri, Mar 6, 2009 at 3:02 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 45 quoted lines
>
> 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.
Previous: Junio C HamanoNext: Junio C Hamano
Message 12 of 17 in “orthogonal cases of log --date option”
  1. Miles BaderMar 3, 2009
  2. Jeff KingMar 3, 2009
  3. Junio C HamanoMar 3, 2009
  4. Jeff KingMar 5, 2009
  5. Jay SoffianMar 5, 2009
  6. Jeff KingMar 5, 2009
  7. Junio C HamanoMar 5, 2009
  8. Jeff KingMar 6, 2009
  9. Junio C HamanoMar 6, 2009
  10. Jay SoffianMar 6, 2009
  11. Junio C HamanoMar 6, 2009
  12. Jay SoffianMar 6, 2009
  13. Junio C HamanoMar 6, 2009
  14. Jeff KingMar 6, 2009
  15. Jeff KingMar 6, 2009
  16. Jeff KingMar 6, 2009
  17. Miles BaderMar 6, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.