From: Junio C Hamano Date: Thu, 22 Jun 2017 21:15:25 +0000 (-0700) Subject: Merge branch 'rs/strbuf-addftime-zZ' X-Git-Tag: v2.14.0-rc0~72 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9eafe86d58a2d2b30e8b33f6697519fc7f104443;p=git Merge branch 'rs/strbuf-addftime-zZ' As there is no portable way to pass timezone information to strftime, some output format from "git log" and friends are impossible to produce. Teach our own strbuf_addftime to replace %z and %Z with caller-supplied values to help working around this. * rs/strbuf-addftime-zZ: date: use localtime() for "-local" time formats t0006: check --date=format zone offsets strbuf: let strbuf_addftime handle %z and %Z itself --- 9eafe86d58a2d2b30e8b33f6697519fc7f104443 diff --cc date.c index 63fa99685e,5580c40ac0..1fd6d66375 --- a/date.c +++ b/date.c @@@ -70,6 -60,12 +70,12 @@@ static struct tm *time_to_tm(timestamp_ return gmtime(&t); } -static struct tm *time_to_tm_local(unsigned long time) ++static struct tm *time_to_tm_local(timestamp_t time) + { + time_t t = time; + return localtime(&t); + } + /* * What value of "tz" was in effect back then at "time" in the * local timezone? diff --cc t/t0006-date.sh index 42d4ea61ef,8e219b7c51..7ac9466d50 --- a/t/t0006-date.sh +++ b/t/t0006-date.sh @@@ -51,10 -53,20 +53,20 @@@ check_show iso-local "$TIME" '2016-06-1 check_show raw-local "$TIME" '1466000000 +0000' check_show unix-local "$TIME" '1466000000' + check_show 'format:%z' "$TIME" '+0200' + check_show 'format-local:%z' "$TIME" '+0000' + check_show 'format:%Z' "$TIME" '' + check_show 'format-local:%Z' "$TIME" 'UTC' + check_show 'format:%%z' "$TIME" '%z' + check_show 'format-local:%%z' "$TIME" '%z' + + check_show 'format:%Y-%m-%d %H:%M:%S' "$TIME" '2016-06-15 16:13:20' + check_show 'format-local:%Y-%m-%d %H:%M:%S' "$TIME" '2016-06-15 09:13:20' '' EST5 + # arbitrary time absurdly far in the future FUTURE="5758122296 -0400" -check_show iso "$FUTURE" "2152-06-19 18:24:56 -0400" LONG_IS_64BIT -check_show iso-local "$FUTURE" "2152-06-19 22:24:56 +0000" LONG_IS_64BIT +check_show iso "$FUTURE" "2152-06-19 18:24:56 -0400" TIME_IS_64BIT,TIME_T_IS_64BIT +check_show iso-local "$FUTURE" "2152-06-19 22:24:56 +0000" TIME_IS_64BIT,TIME_T_IS_64BIT check_parse() { echo "$1 -> $2" >expect