<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/date.c, branch v2.35.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.35.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.35.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2021-11-04T19:38:09Z</updated>
<entry>
<title>strbuf_addftime(): handle "%s" manually</title>
<updated>2021-11-04T19:38:09Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2021-11-02T11:35:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9b591b94038ce8cab9baf66a83ad752824854163'/>
<id>urn:sha1:9b591b94038ce8cab9baf66a83ad752824854163</id>
<content type='text'>
The strftime() function has a non-standard "%s" extension, which prints
the number of seconds since the epoch. But the "struct tm" we get has
already been adjusted for a particular time zone; going back to an epoch
time requires knowing that zone offset. Since strftime() doesn't take
such an argument, round-tripping to a "struct tm" and back to the "%s"
format may produce the wrong value (off by tz_offset seconds).

Since we're already passing in the zone offset courtesy of c3fbf81a85
(strbuf: let strbuf_addftime handle %z and %Z itself, 2017-06-15), we
can use that same value to adjust our epoch seconds accordingly.

Note that the description above makes it sound like strftime()'s "%s" is
useless (and really, the issue is shared by mktime(), which is what
strftime() would use under the hood). But it gets the two cases for
which it's designed correct:

  - the result of gmtime() will have a zero offset, so no adjustment is
    necessary

  - the result of localtime() will be offset by the local zone offset,
    and mktime() and strftime() are defined to assume this offset when
    converting back (there's actually some magic here; some
    implementations record this in the "struct tm", but we can't
    portably access or manipulate it. But they somehow "know" whether a
    "struct tm" is from gmtime() or localtime()).

This latter point means that "format-local:%s" actually works correctly
already, because in that case we rely on the system routines due to
6eced3ec5e (date: use localtime() for "-local" time formats,
2017-06-15). Our problem comes when trying to show times in the author's
zone, as the system routines provide no mechanism for converting in
non-local zones. So in those cases we have a "struct tm" that came from
gmtime(), but has been manipulated according to our offset.

The tests cover the broken round-trip by formatting "%s" for a time in a
non-system timezone. We use the made-up "+1234" here, which has two
advantages. One, we know it won't ever be the real system zone (and so
we're actually testing a case that would break). And two, since it has a
minute component, we're testing the full decoding of the +HHMM zone into
a number of seconds. Likewise, we test the "-1234" variant to make sure
there aren't any sign mistakes.

There's one final test, which covers "format-local:%s". As noted, this
already passes, but it's important to check that we didn't regress this
case. In particular, the caller in show_date() is relying on localtime()
to have done the zone adjustment, independent of any tz_offset we
compute ourselves. These should match up, since our local_tzoffset() is
likewise built around localtime(). But it would be easy for a caller to
forget to pass in a correct tz_offset to strbuf_addftime(). Fortunately
show_date() does this correctly (it has to because of the existing
handling of %z), and the test continues to pass. So this one is just
future-proofing against a change in our assumptions.

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>comments: avoid using the gender of our users</title>
<updated>2021-06-16T02:25:11Z</updated>
<author>
<name>Felipe Contreras</name>
<email>felipe.contreras@gmail.com</email>
</author>
<published>2021-06-15T14:11:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0e20b229eea63716cdd1bea916b7e416f450278a'/>
<id>urn:sha1:0e20b229eea63716cdd1bea916b7e416f450278a</id>
<content type='text'>
We generally avoid specifying the gender of our users in order to be
more inclusive, but sometimes a few slip by due to habit.

Since by doing a little bit of rewording we can avoid this irrelevant
detail, let's do so.

Inspired-by: Derrick Stolee &lt;dstolee@microsoft.com&gt;
Helped-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Felipe Contreras &lt;felipe.contreras@gmail.com&gt;
Signed-off-by: Derrick Stolee &lt;dstolee@microsoft.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>date.c: allow compact version of ISO-8601 datetime</title>
<updated>2020-04-24T21:06:09Z</updated>
<author>
<name>Đoàn Trần Công Danh</name>
<email>congdanhqx@gmail.com</email>
</author>
<published>2020-04-24T15:07:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=544ed961a50c3442a3ec5643f2c443cd3e17311a'/>
<id>urn:sha1:544ed961a50c3442a3ec5643f2c443cd3e17311a</id>
<content type='text'>
Signed-off-by: Đoàn Trần Công Danh &lt;congdanhqx@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>date.c: skip fractional second part of ISO-8601</title>
<updated>2020-04-24T21:06:09Z</updated>
<author>
<name>Đoàn Trần Công Danh</name>
<email>congdanhqx@gmail.com</email>
</author>
<published>2020-04-24T15:07:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b784840ca84c708708d1ab0b872eb3a6fb3200b5'/>
<id>urn:sha1:b784840ca84c708708d1ab0b872eb3a6fb3200b5</id>
<content type='text'>
git-commit(1) says ISO-8601 is one of our supported date format.

ISO-8601 allows timestamps to have a fractional number of seconds.
We represent time only in terms of whole seconds, so we never bothered
parsing fractional seconds. However, it's better for us to parse and
throw away the fractional part than to refuse to parse the timestamp
at all.

And refusing parsing fractional second part may confuse the parse to
think fractional and timezone as day and month in this example:

	2008-02-14 20:30:45.019-04:00

While doing this, make sure that we only interpret the number after the
second and the dot as fractional when and only when the date is known,
since only ISO-8601 allows the fractional part, and we've taught our
users to interpret "12:34:56.7.days.ago" as a way to specify a time
relative to current time.

Reported-by: Brian M. Carlson &lt;sandals@crustytoothpaste.net&gt;
Helped-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Đoàn Trần Công Danh &lt;congdanhqx@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>date.c: validate and set time in a helper function</title>
<updated>2020-04-24T21:06:09Z</updated>
<author>
<name>Đoàn Trần Công Danh</name>
<email>congdanhqx@gmail.com</email>
</author>
<published>2020-04-24T15:07:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4f89f4fc9ac494fde3f3bede19a7599f77afe8dc'/>
<id>urn:sha1:4f89f4fc9ac494fde3f3bede19a7599f77afe8dc</id>
<content type='text'>
In a later patch, we will reuse this logic, move it to a helper, now.

While we're at it, explicit states that we intentionally ignore
old-and-defective 2nd leap second.

Signed-off-by: Đoàn Trần Công Danh &lt;congdanhqx@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>date.c: s/is_date/set_date/</title>
<updated>2020-04-23T20:22:00Z</updated>
<author>
<name>Đoàn Trần Công Danh</name>
<email>congdanhqx@gmail.com</email>
</author>
<published>2020-04-23T13:52:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c933b28d87062a0c68de298900b9060f577f865a'/>
<id>urn:sha1:c933b28d87062a0c68de298900b9060f577f865a</id>
<content type='text'>
The function is_date, confusingly also set tm_year. tm_mon, and tm_mday
after validating input.

Rename to set_date to reflect its real usage.

Also, change return value is 0 on success and -1 on failure following
our convention on function do some real work.

Signed-off-by: Đoàn Trần Công Danh &lt;congdanhqx@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>date.c: switch to reentrant {gm,local}time_r</title>
<updated>2019-11-30T21:50:48Z</updated>
<author>
<name>Doan Tran Cong Danh</name>
<email>congdanhqx@gmail.com</email>
</author>
<published>2019-11-28T12:25:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ccd469450aaf62e6d0ce41a9738823d19d749a78'/>
<id>urn:sha1:ccd469450aaf62e6d0ce41a9738823d19d749a78</id>
<content type='text'>
Originally, git was intended to be single-thread executable.
`gmtime(3)' and `localtime(3)' can be used in such codebase
for cleaner code.

Overtime, we're employing multithread in our code base.

Let's phase out `gmtime(3)' and `localtime(3)' in favour of
`gmtime_r(3)' and `localtime_r(3)'.

Signed-off-by: Doan Tran Cong Danh &lt;congdanhqx@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Quit passing 'now' to date code</title>
<updated>2019-09-12T18:03:51Z</updated>
<author>
<name>Stephen P. Smith</name>
<email>ischis2@cox.net</email>
</author>
<published>2019-09-12T04:11:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=29f4332e66abf41e90d2f38e62370a42d8549c7e'/>
<id>urn:sha1:29f4332e66abf41e90d2f38e62370a42d8549c7e</id>
<content type='text'>
Commit b841d4ff43 (Add `human` format to test-tool, 2019-01-28) added
a get_time() function which allows $GIT_TEST_DATE_NOW in the
environment to override the current time. So we no longer need to
interpret that variable in cmd__date().

Therefore, we can stop passing the "now" parameter down through the
date functions, since nobody uses them. Note that we do need to make
sure all of the previous callers that took a "now" parameter are
correctly using get_time().

Signed-off-by: Stephen P. Smith &lt;ischis2@cox.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>completion: add more parameter value completion</title>
<updated>2019-02-20T20:31:56Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2019-02-16T11:24:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5a59a2301f6ec9bcf1b101edb9ca33beb465842f'/>
<id>urn:sha1:5a59a2301f6ec9bcf1b101edb9ca33beb465842f</id>
<content type='text'>
This adds value completion for a couple more paramters. To make it
easier to maintain these hard coded lists, add a comment at the original
list/code to remind people to update git-completion.bash too.

Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'lt/date-human'</title>
<updated>2019-02-07T06:05:24Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-02-07T06:05:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ecbe1beb8e41664ac00581234a449c4487600e1d'/>
<id>urn:sha1:ecbe1beb8e41664ac00581234a449c4487600e1d</id>
<content type='text'>
A new date format "--date=human" that morphs its output depending
on how far the time is from the current time has been introduced.
"--date=auto" can be used to use this new format when the output is
going to the pager or to the terminal and otherwise the default
format.

* lt/date-human:
  Add `human` date format tests.
  Add `human` format to test-tool
  Add 'human' date format documentation
  Replace the proposed 'auto' mode with 'auto:'
  Add 'human' date format
</content>
</entry>
</feed>
