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

Re: [PATCH] pretty: Provide a strict ISO8601 date format

From
SSScott Schmit <i.grok@comcast.net>
Date
Aug 29, 2014, 17:44 UTC
Message-ID
<20140829174439.GA10274@odin.ulthar.us>
In-Reply-To
<xmqq61hc8bvq.fsf@gitster.dls.corp.google.com>
On Thu, Aug 28, 2014 at 03:53:13PM -0700, Junio C Hamano wrote:
Show 12 quoted lines
> Beat Bolli writes:
> > +	else if (mode == DATE_ISO8601_STRICT)
> > +		strbuf_addf(&timebuf, "%04d-%02d-%02dT%02d:%02d:%02d%+03d:%02d",
> > +				tm->tm_year + 1900,
> > +				tm->tm_mon + 1,
> > +				tm->tm_mday,
> > +				tm->tm_hour, tm->tm_min, tm->tm_sec,
> > +				tz / 100, abs(tz % 100));
> 
> Wouldn't this misidentify a zone that is 30 minutes off of GMT,
> i.e. tz == -30?  tz/100 would not be negative and "%+03d:" would
> happily show "+00:", no?

No. strbuf_addf uses strbuf_vaddf which uses vsnprintf(3). From man vsnprintf(3):

Show 8 quoted lines
>   The flag characters
>       The character % is followed by zero or more of the following
>       flags:
>
>       +      A sign (+ or -) should always be placed before a number
>              produced by a signed conversion.  By default a sign is
>              used only for negative numbers.  A + overrides a space if
>              both are used.
Perhaps you misread "%+03d:" as "+%02d:"?
-- 
Scott Schmit
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 6 in “pretty: Provide a strict ISO8601 date format”
  1. pretty: Provide a strict ISO8601 date formatBeat Bolli, Aug 28, 2014
  2. Junio C HamanoAug 28, 2014
  3. Scott SchmitAug 29, 2014
  4. Junio C HamanoAug 29, 2014
  5. Scott SchmitAug 29, 2014
  6. Junio C HamanoAug 29, 2014

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.