Re: [Bug] git-log prints wrong unixtime with --date=format:%s

2016-05-19 Thread Michael Heerdegen
Jeff King  writes:

> Oh, I agree that unix times are handy. I just think that "use %at in the
> pretty-format, instead of %ad and then %s in the date-format" is not
> such a bad workaround.

I had missed %at (and %ct).  Yes, works perfectly - thanks for the hint.


Regards,

Michael.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Bug] git-log prints wrong unixtime with --date=format:%s

2016-05-18 Thread Jeff King
On Thu, May 19, 2016 at 01:05:28AM +0200, Michael Heerdegen wrote:

> Jeff King  writes:
> 
> >   3. The epoch times for the latter lines should match.
> 
> FWIW, I think the epoch time is the most practical way to transfer the
> time of a commit into a different program.  When this program wants to
> do it's own date arithmetic with it, unix time is just nice (no time
> format parsing needed).
> 
> That's why it would be good if the unix time values could be relied on.

Oh, I agree that unix times are handy. I just think that "use %at in the
pretty-format, instead of %ad and then %s in the date-format" is not
such a bad workaround.

> Conclusion: in addition to 3., I wished both epoch times were also
> correct per se.

The %at one should be correct, no? If it's not, that's a separate bug.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Bug] git-log prints wrong unixtime with --date=format:%s

2016-05-18 Thread Michael Heerdegen
Jeff King  writes:

>   3. The epoch times for the latter lines should match.

FWIW, I think the epoch time is the most practical way to transfer the
time of a commit into a different program.  When this program wants to
do it's own date arithmetic with it, unix time is just nice (no time
format parsing needed).

That's why it would be good if the unix time values could be relied on.

Conclusion: in addition to 3., I wished both epoch times were also
correct per se.


Regards,

Michael.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Bug] git-log prints wrong unixtime with --date=format:%s

2016-05-18 Thread Michael Heerdegen
Jeff King  writes:

> This is probably a totally separate issue, as it would not be using
> strftime (or IIRC, any of the standard time functions at all). Do you
> have a detailed example that shows the problem?

Ok, this was probably false alarm.  Magit (An Emacs Git front end) shows
rounded duration values (rounded hours in my case) in its log views, I
think I just got confused because of this.  In my tests now, the results
were as expected.


Thanks,

Michael.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Bug] git-log prints wrong unixtime with --date=format:%s

2016-05-18 Thread Jeff King
On Wed, May 18, 2016 at 12:44:43PM -0400, Randall S. Becker wrote:

> Off the wall: Dealing in a dispersed team sharing a server that has a
> timezone local for only two of the members, git log messes with me also from
> a TZ POV. I would like to suggest a more general solution, like configuring
> my own TZ in ~/.gitconfig which would potentially allow an override on the
> command line. Would user.timezone be helpful in this situation and if set,
> call setenv("TZ=...")? It's not an issue when I'm local, but if I touch a
> clone on the server, even I get confused around DST changes in October ;).

I'm not sure I understand the problem. If you don't like the local
timezone used on the server, why don't you set TZ there? What does
it buy us to introduce a git config option to do the same thing?

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Bug] git-log prints wrong unixtime with --date=format:%s

2016-05-18 Thread Jeff King
On Wed, May 18, 2016 at 09:21:34AM -0700, Junio C Hamano wrote:

> Jeff King  writes:
> 
> > I tried a few obvious things, but couldn't make anything work. Setting
> > "timezone" manually seems to do nothing. It's supposed to be set by
> > putting the right thing in $TZ and then calling tzset(). So I tried
> > munging $TZ to something like "+0200". It did have _some_ effect, but I
> 
> Wouldn't that be more like "UTC+0200"?

Maybe. I tried several different things, and couldn't make it work
sensibly with any of them. My test case is basically:

  git log --format="%ad%n%at" --date=format:'%H:%M %z (%Z)%n%s'

Which should give three lines: the human-readable time and date,
strftime's epoch time, and git's epoch time. And the following
conditions should be met:

  1. The human-readable time is in the author's timezone (or the user's
 if you use format-local).

  2. The zone offset and name in the first line matches the time we
 show.

  3. The epoch times for the latter lines should match.

We currently get (1) right (which is good, because it is IMHO the most
important). I haven't been able to get (2) to change at all, no matter
what I do. And (3) is the subject of debate here; I suspect I could make
it work at the cost of breaking (1) by giving a "struct tm" that is in
UTC.

> In any case, I do not think anybody wants to do tzset() on each and
> every commit while running "git log".  Can we declare "format:"
> will always use the local timezone, or something?

I think that is basically the case already. It is in the author's
timezone or in the viewing user's timezone (as reported by localtime()),
and everything seems to work except the %z zone information and the %s
format.

For a raw "%s" date-format, my suggestion is: don't. It is redundant
with --date=raw.

I'd love to make %z work, but I have no idea how.

So I guess we could list those in BUGS in one of the manpages.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [Bug] git-log prints wrong unixtime with --date=format:%s

2016-05-18 Thread Randall S. Becker
On May 18, 2016 12:22 PM Jeff King wrote:
> > I tried a few obvious things, but couldn't make anything work. Setting
> > "timezone" manually seems to do nothing. It's supposed to be set by
> > putting the right thing in $TZ and then calling tzset(). So I tried
> > munging $TZ to something like "+0200". It did have _some_ effect, but
> > I
> 
> Wouldn't that be more like "UTC+0200"?
> 
> In any case, I do not think anybody wants to do tzset() on each and every
> commit while running "git log".  Can we declare "format:"
> will always use the local timezone, or something?

Off the wall: Dealing in a dispersed team sharing a server that has a
timezone local for only two of the members, git log messes with me also from
a TZ POV. I would like to suggest a more general solution, like configuring
my own TZ in ~/.gitconfig which would potentially allow an override on the
command line. Would user.timezone be helpful in this situation and if set,
call setenv("TZ=...")? It's not an issue when I'm local, but if I touch a
clone on the server, even I get confused around DST changes in October ;).

Cheers,
Randall

-- Brief whoami: NonStop developer since approximately
UNIX(421664400)/NonStop(2112884442)
-- In my real life, I talk too much.



--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Bug] git-log prints wrong unixtime with --date=format:%s

2016-05-18 Thread Junio C Hamano
Jeff King  writes:

> I tried a few obvious things, but couldn't make anything work. Setting
> "timezone" manually seems to do nothing. It's supposed to be set by
> putting the right thing in $TZ and then calling tzset(). So I tried
> munging $TZ to something like "+0200". It did have _some_ effect, but I

Wouldn't that be more like "UTC+0200"?

In any case, I do not think anybody wants to do tzset() on each and
every commit while running "git log".  Can we declare "format:"
will always use the local timezone, or something?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Bug] git-log prints wrong unixtime with --date=format:%s

2016-05-17 Thread Jeff King
On Tue, May 17, 2016 at 08:40:08PM -0400, Jeff King wrote:

> So we need some way to tell strftime "...and by the way, this is the
> timezone for the value we are currently feeding you." There isn't a slot
> in "struct tm" for that, but I think maybe you can hack around it by
> setting the global "timezone" variable (and then restoring it
> afterwards).

I tried a few obvious things, but couldn't make anything work. Setting
"timezone" manually seems to do nothing. It's supposed to be set by
putting the right thing in $TZ and then calling tzset(). So I tried
munging $TZ to something like "+0200". It did have _some_ effect, but I
couldn't get it to behave correctly in all situations. And using "%z"
and "%Z" always just gives GMT.

So I dunno. Perhaps there is some way to coax sane behavior out of
strftime, but I could not figure it out. Suggestions welcome.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Bug] git-log prints wrong unixtime with --date=format:%s

2016-05-17 Thread Jeff King
On Tue, May 17, 2016 at 07:25:31PM +0200, Michael Heerdegen wrote:

> Michael Heerdegen  writes:
> 
> > the command
> >
> >git log --pretty=format:%ad --date=format:%s
> >
> > displays wrong unixtime values; apparently how much the printed value
> > differs from the expected value depends on the system's time zone and
> > whether daylight savings time is enabled or not.
> 
> Two more comments:
> 
>   - --date=raw seems to work correctly (though the doc tells it would
> also use "%s").

I think the doc is misleading there. None of the date formats except the
recently added "--date=format" use strftime at all.

The problem is almost certainly some mismatch between git's idea of the
timezone and what we are feeding to strftime. I'm not sure if it will be
solvable, though. strftime() takes a "struct tm", which has no timezone
field. We feed it a "struct tm" either in the author's timezone or in
the user's timezone (if "format-local" was used). We could feed it in
UTC, but I'm not sure that solves the problem, and it probably makes new
ones.

In your examples, you showed that setting $TZ changes the epoch time
strftime gives us. Which probably means that it is guessing the fed
"struct tm" is in the local timezone, which would still be wrong.

And even if that did work, feeding it UTC means that all of the other
non-%s values would be in UTC, not in the author's or user's timezone.

So we need some way to tell strftime "...and by the way, this is the
timezone for the value we are currently feeding you." There isn't a slot
in "struct tm" for that, but I think maybe you can hack around it by
setting the global "timezone" variable (and then restoring it
afterwards).

>   - When specifying versions like @{N hours}, the result seems to differ
> (by one hour?) from what I expect, too.

This is probably a totally separate issue, as it would not be using
strftime (or IIRC, any of the standard time functions at all). Do you
have a detailed example that shows the problem?

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Bug] git-log prints wrong unixtime with --date=format:%s

2016-05-17 Thread Michael Heerdegen
Michael Heerdegen  writes:

> the command
>
>git log --pretty=format:%ad --date=format:%s
>
> displays wrong unixtime values; apparently how much the printed value
> differs from the expected value depends on the system's time zone and
> whether daylight savings time is enabled or not.

Two more comments:

  - --date=raw seems to work correctly (though the doc tells it would
also use "%s").

  - When specifying versions like @{N hours}, the result seems to differ
(by one hour?) from what I expect, too.


Thanks,

Michael.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html