<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/git.git/date.c, branch v1.7.6.3</title>
<subtitle>Git
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/git.git/atom?h=v1.7.6.3</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/atom?h=v1.7.6.3'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/'/>
<updated>2011-04-21T02:23:16Z</updated>
<entry>
<title>date: avoid "X years, 12 months" in relative dates</title>
<updated>2011-04-21T02:23:16Z</updated>
<author>
<name>Michael J Gruber</name>
<email>git@drmicha.warpmail.net</email>
</author>
<published>2011-04-20T09:12:11Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=f1e9c548ce45005521892af0299696204ece286b'/>
<id>urn:sha1:f1e9c548ce45005521892af0299696204ece286b</id>
<content type='text'>
When relative dates are more than about a year ago, we start
writing them as "Y years, M months".  At the point where we
calculate Y and M, we have the time delta specified as a
number of days. We calculate these integers as:

  Y = days / 365
  M = (days % 365 + 15) / 30

This rounds days in the latter half of a month up to the
nearest month, so that day 16 is "1 month" (or day 381 is "1
year, 1 month").

We don't round the year at all, though, meaning we can end
up with "1 year, 12 months", which is silly; it should just
be "2 years".

Implement this differently with months of size

  onemonth = 365/12

so that

  totalmonths = (long)( (days + onemonth/2)/onemonth )
  years = totalmonths / 12
  months = totalmonths % 12

In order to do this without floats, we write the first formula as

  totalmonths = (days*12*2 + 365) / (365*2)

Tests and inspiration by Jeff King.

Helped-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Michael J Gruber &lt;git@drmicha.warpmail.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Export parse_date_basic() to convert a date string to timestamp</title>
<updated>2010-07-15T22:35:12Z</updated>
<author>
<name>Jonathan Nieder</name>
<email>jrnieder@gmail.com</email>
</author>
<published>2010-07-15T16:22:57Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=9644c0616374f8c621b10793b1732b26a0482820'/>
<id>urn:sha1:9644c0616374f8c621b10793b1732b26a0482820</id>
<content type='text'>
approxidate() is not appropriate for reading machine-written dates
because it guesses instead of erroring out on malformed dates.
parse_date() is less convenient since it returns its output as a
string.  So export the underlying function that writes a timestamp.

While at it, change the return value to match the usual convention:
return 0 for success and -1 for failure.

Signed-off-by: Jonathan Nieder &lt;jrnieder@gmail.com&gt;
Acked-by: Ramkumar Ramachandra &lt;artagnon@gmail.com&gt;
Signed-off-by: Ramkumar Ramachandra &lt;artagnon@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>parse_date: fix signedness in timezone calculation</title>
<updated>2010-07-05T18:57:07Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2010-07-04T11:00:17Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=9ba0f0334dd505f78e0374bbe857c5e202f5a778'/>
<id>urn:sha1:9ba0f0334dd505f78e0374bbe857c5e202f5a778</id>
<content type='text'>
When no timezone is specified, we deduce the offset by
subtracting the result of mktime from our calculated
timestamp.

However, our timestamp is stored as an unsigned integer,
meaning we perform the subtraction as unsigned. For a
negative offset, this means we wrap to a very high number,
and our numeric timezone is in the millions of hours. You
can see this bug by doing:

   $ TZ=EST \
     GIT_AUTHOR_DATE='2010-06-01 10:00' \
     git commit -a -m foo
   $ git cat-file -p HEAD | grep author
   author Jeff King &lt;peff@peff.net&gt; 1275404416 +119304128

Instead, we should perform this subtraction as a time_t, the
same type that mktime returns.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'rr/parse-date-refactor'</title>
<updated>2010-06-21T13:02:47Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2010-06-21T13:02:47Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=8718e875080767f2c8d06c55c3fb5a6dddf0e5a0'/>
<id>urn:sha1:8718e875080767f2c8d06c55c3fb5a6dddf0e5a0</id>
<content type='text'>
* rr/parse-date-refactor:
  Refactor parse_date for approxidate functions
</content>
</entry>
<entry>
<title>Refactor parse_date for approxidate functions</title>
<updated>2010-06-07T22:52:43Z</updated>
<author>
<name>Ramkumar Ramachandra</name>
<email>artagnon@gmail.com</email>
</author>
<published>2010-06-03T20:28:55Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=c5043cc18579854681aa51ddb6e744fe2db24f51'/>
<id>urn:sha1:c5043cc18579854681aa51ddb6e744fe2db24f51</id>
<content type='text'>
approxidate_relative and approxidate_careful both use parse_date to
dump the timestamp to a character buffer and parse it back into a long
unsigned using strtoul(). Avoid doing this by creating a new
parse_date_toffset method.

Noticed-by: Jonathan Nieder &lt;jrnieder@gmail.com&gt;
Signed-off-by: Ramkumar Ramachandra &lt;artagnon@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Add "Z" as an alias for the timezone "UTC"</title>
<updated>2010-05-19T05:00:17Z</updated>
<author>
<name>Marcus Comstedt</name>
<email>marcus@mc.pp.se</email>
</author>
<published>2010-05-17T19:07:10Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=75b37e704781a9ae4db2f0beaaa023638c06490d'/>
<id>urn:sha1:75b37e704781a9ae4db2f0beaaa023638c06490d</id>
<content type='text'>
The name "Z" for the UTC timezone is required to properly parse ISO 8601
timestamps.  Add it to the list of recognized timezones.

Because timezone names can be shorter than 3 letters, loosen the
restriction in match_alpha() that used to require at least 3 letters to
match to allow a short timezone name as long as it matches exactly.  Prior
to the introduction of the "Z" zone, this already affected the timezone
"NT" (Nome).

Signed-off-by: Marcus Comstedt &lt;marcus@mc.pp.se&gt;
Reviewed-by: Jay Soffian &lt;jaysoffian@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jc/maint-reflog-bad-timestamp'</title>
<updated>2010-01-27T22:57:37Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2010-01-27T22:57:37Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=103209c6782586d92b04ee1fc71c0fd6f6385f5f'/>
<id>urn:sha1:103209c6782586d92b04ee1fc71c0fd6f6385f5f</id>
<content type='text'>
* jc/maint-reflog-bad-timestamp:
  t0101: use a fixed timestamp when searching in the reflog
  Update @{bogus.timestamp} fix not to die()
  approxidate_careful() reports errorneous date string
</content>
</entry>
<entry>
<title>approxidate_careful() reports errorneous date string</title>
<updated>2010-01-26T21:51:41Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2010-01-26T19:58:00Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=93cfa7c7a85efbdb00daade4ad0afc11bd2fdf37'/>
<id>urn:sha1:93cfa7c7a85efbdb00daade4ad0afc11bd2fdf37</id>
<content type='text'>
For a long time, the time based reflog syntax (e.g. master@{yesterday})
didn't complain when the "human readable" timestamp was misspelled, as
the underlying mechanism tried to be as lenient as possible.  The funny
thing was that parsing of "@{now}" even relied on the fact that anything
not recognized by the machinery returned the current timestamp.

Introduce approxidate_careful() that takes an optional pointer to an
integer, that gets assigned 1 when the input does not make sense as a
timestamp.

As I am too lazy to fix all the callers that use approxidate(), most of
the callers do not take advantage of the error checking, but convert the
code to parse reflog to use it as a demonstration.

Tests are mostly from Jeff King.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>date.c: mark file-local function static</title>
<updated>2010-01-20T22:37:17Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2010-01-12T07:52:47Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=23418ea95f83177df19bfe18af33650b87ec2a8a'/>
<id>urn:sha1:23418ea95f83177df19bfe18af33650b87ec2a8a</id>
<content type='text'>
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Fix '--relative-date'</title>
<updated>2009-10-03T10:04:38Z</updated>
<author>
<name>Johan Sageryd</name>
<email>j416@1616.se</email>
</author>
<published>2009-10-03T04:20:18Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/git.git/commit/?id=dbc1b1f71052c084a84b5c395e1cb4b5ae526fcb'/>
<id>urn:sha1:dbc1b1f71052c084a84b5c395e1cb4b5ae526fcb</id>
<content type='text'>
This fixes '--relative-date' so that it does not give '0
year, 12 months', for the interval 360 &lt;= diff &lt; 365.

Signed-off-by: Johan Sageryd &lt;j416@1616.se&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
</content>
</entry>
</feed>
