commit 283939fb8245f1600227fa1cde3c5623666fac8d from: Lucas Gabriel Vuotto via: Omar Polo date: Tue Apr 23 21:03:45 2024 UTC replace date, strftime %G-%m-%d with %F Use the more predictable %F, aka %Y-%m-%d, instead of %G-%m-%d. %G follows the definition of ISO-8601 week-based year, which is weird. In particular, 2024 is one of such years with weird behaviour: $ date -jf %Y-%m-%d +"%F %G-%m-%d" 2024-12-30 2024-12-30 2025-12-30 Diff from Lucas Gabriel Vuotto (thanks!); stsp agrees commit - 2c1b17802598396420e45c97fe4e8d2d03fcb523 commit + 283939fb8245f1600227fa1cde3c5623666fac8d blob - 38191d6109e5f5caf08654969f4f3af3d9fb2c70 blob + 8371183b94f386e42d65020ff1fed931a40906e3 --- cvg/cvg.c +++ cvg/cvg.c @@ -3552,7 +3552,7 @@ print_commit_oneline(struct got_commit_object *commit, err = got_error_from_errno("gmtime_r"); goto done; } - if (strftime(datebuf, sizeof(datebuf), "%G-%m-%d ", &tm) == 0) { + if (strftime(datebuf, sizeof(datebuf), "%F ", &tm) == 0) { err = got_error(GOT_ERR_NO_SPACE); goto done; } @@ -4989,8 +4989,7 @@ blame_cb(void *arg, int nlines, int lineno, committer_time = got_object_commit_get_committer_time(commit); if (gmtime_r(&committer_time, &tm) == NULL) return got_error_from_errno("gmtime_r"); - if (strftime(bline->datebuf, sizeof(bline->datebuf), "%G-%m-%d", - &tm) == 0) { + if (strftime(bline->datebuf, sizeof(bline->datebuf), "%F", &tm) == 0) { err = got_error(GOT_ERR_NO_SPACE); goto done; } blob - b55e991971271638732739463b3a95ee39f126af blob + 9b22bd01524107cae5a5dc3a2b85913cadb5bd7b --- got/got.c +++ got/got.c @@ -4252,7 +4252,7 @@ print_commit_oneline(struct got_commit_object *commit, err = got_error_from_errno("gmtime_r"); goto done; } - if (strftime(datebuf, sizeof(datebuf), "%G-%m-%d ", &tm) == 0) { + if (strftime(datebuf, sizeof(datebuf), "%F ", &tm) == 0) { err = got_error(GOT_ERR_NO_SPACE); goto done; } @@ -5728,8 +5728,7 @@ blame_cb(void *arg, int nlines, int lineno, committer_time = got_object_commit_get_committer_time(commit); if (gmtime_r(&committer_time, &tm) == NULL) return got_error_from_errno("gmtime_r"); - if (strftime(bline->datebuf, sizeof(bline->datebuf), "%G-%m-%d", - &tm) == 0) { + if (strftime(bline->datebuf, sizeof(bline->datebuf), "%F", &tm) == 0) { err = got_error(GOT_ERR_NO_SPACE); goto done; } @@ -10968,7 +10967,7 @@ get_commit_brief_str(char **brief_str, struct got_comm committer_time = got_object_commit_get_committer_time(commit); if (gmtime_r(&committer_time, &tm) == NULL) return got_error_from_errno("gmtime_r"); - if (strftime(datebuf, sizeof(datebuf), "%G-%m-%d", &tm) == 0) + if (strftime(datebuf, sizeof(datebuf), "%F", &tm) == 0) return got_error(GOT_ERR_NO_SPACE); author0 = strdup(got_object_commit_get_author(commit)); blob - 9fa5822a667b83bb176b4454365f124f1d2ea2f7 blob + 171fa5d55b41f501784c01e7484230473533e508 --- gotd/libexec/got-notify-email/got-notify-email.c +++ gotd/libexec/got-notify-email/got-notify-email.c @@ -242,7 +242,7 @@ print_date(int s, char *date, int shortfmt) return got_poll_write_full(s, " UTC\n", 5); } - if (strftime(datebuf, sizeof(datebuf), "%G-%m-%d ", &tm) == 0) + if (strftime(datebuf, sizeof(datebuf), "%F ", &tm) == 0) return got_error_set_errno(EINVAL, "invalid timestamp"); return got_poll_write_full(s, datebuf, strlen(datebuf)); } blob - bd3939fbbae66ba3fc54ef4ac319959561b56a2c blob + 5bcdf61f67c447df889e0dce4ed81ce7e39d19e0 --- gotwebd/got_operations.c +++ gotwebd/got_operations.c @@ -944,8 +944,7 @@ got_gotweb_blame_cb(void *arg, int nlines, int lineno, committer_time = got_object_commit_get_committer_time(commit); if (gmtime_r(&committer_time, &tm) == NULL) return got_error_from_errno("gmtime_r"); - if (strftime(bline->datebuf, sizeof(bline->datebuf), "%G-%m-%d", - &tm) == 0) { + if (strftime(bline->datebuf, sizeof(bline->datebuf), "%F", &tm) == 0) { err = got_error(GOT_ERR_NO_SPACE); goto done; } blob - 4281311847e1767c625823074c5208dc9f177123 blob + d60fc3d989f80b6803c66daddd2280f9ac6bee96 --- regress/cmdline/blame.sh +++ regress/cmdline/blame.sh @@ -65,7 +65,7 @@ test_blame_basic() { local short_commit2=`trim_obj_id 32 $commit2` local short_commit3=`trim_obj_id 32 $commit3` - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -r $author_time +"%F"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected echo "2) $short_commit2 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected echo "3) $short_commit3 $d $GOT_AUTHOR_8 3" >> $testroot/stdout.expected @@ -113,7 +113,7 @@ test_blame_tag() { local short_commit1=`trim_obj_id 32 $commit1` local short_commit2=`trim_obj_id 32 $commit2` - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -r $author_time +"%F"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected echo "2) $short_commit2 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected @@ -149,7 +149,7 @@ test_blame_file_single_line() { local short_commit1=`trim_obj_id 32 $commit1` - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -r $author_time +"%F"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected cmp -s $testroot/stdout.expected $testroot/stdout @@ -184,7 +184,7 @@ test_blame_file_single_line_no_newline() { local short_commit1=`trim_obj_id 32 $commit1` - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -r $author_time +"%F"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected cmp -s $testroot/stdout.expected $testroot/stdout @@ -213,7 +213,7 @@ test_blame_all_lines_replaced() { (cd $testroot/wt && got blame alpha > $testroot/stdout) - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -r $author_time +"%F"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected echo "2) $short_commit1 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected echo "3) $short_commit1 $d $GOT_AUTHOR_8 3" >> $testroot/stdout.expected @@ -268,7 +268,7 @@ test_blame_lines_shifted_up() { (cd $testroot/wt && got blame alpha > $testroot/stdout) - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -r $author_time +"%F"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected echo "2) $short_commit1 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected echo "3) $short_commit3 $d $GOT_AUTHOR_8 foo" >> $testroot/stdout.expected @@ -327,7 +327,7 @@ test_blame_lines_shifted_down() { (cd $testroot/wt && got blame alpha > $testroot/stdout) - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -r $author_time +"%F"` echo "01) $short_commit1 $d $GOT_AUTHOR_8 1" \ > $testroot/stdout.expected echo "02) $short_commit1 $d $GOT_AUTHOR_8 2" \ @@ -400,7 +400,7 @@ EOF local commit1=`git_show_head $testroot/repo` local short_commit1=`trim_obj_id 32 $commit1` local author_time1=`git_show_author_time $testroot/repo` - local d1=`date -u -r $author_time1 +"%G-%m-%d"` + local d1=`date -u -r $author_time1 +"%F"` cat > $testroot/wt/alpha < $testroot/wt/alpha < $testroot/wt/alpha < $testroot/stdout) @@ -724,7 +724,7 @@ test_blame_added_on_branch() { local short_commit2=`trim_obj_id 32 $commit2` local short_commit3=`trim_obj_id 32 $commit3` - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -r $author_time +"%F"` echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected echo "2) $short_commit2 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected echo "3) $short_commit3 $d $GOT_AUTHOR_8 3" >> $testroot/stdout.expected @@ -795,7 +795,7 @@ test_blame_symlink() { return 1 fi - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -r $author_time +"%F"` echo "1) $short_commit0 $d $GOT_AUTHOR_8 alpha" \ > $testroot/stdout.expected @@ -816,7 +816,7 @@ test_blame_symlink() { return 1 fi - d=`date -u -r $author_time +"%G-%m-%d"` + d=`date -u -r $author_time +"%F"` echo "1) $short_commit0 $d $GOT_AUTHOR_8 beta" \ > $testroot/stdout.expected @@ -966,10 +966,10 @@ EOF (cd $testroot/wt && got blame alpha > $testroot/stdout) - d1=`date -u -r $author_time1 +"%G-%m-%d"` - d2=`date -u -r $author_time2 +"%G-%m-%d"` - d4=`date -u -r $author_time4 +"%G-%m-%d"` - d5=`date -u -r $author_time5 +"%G-%m-%d"` + d1=`date -u -r $author_time1 +"%F"` + d2=`date -u -r $author_time2 +"%F"` + d4=`date -u -r $author_time4 +"%F"` + d5=`date -u -r $author_time5 +"%F"` echo "1) $short_commit5 $d5 $GOT_AUTHOR_8 X" > $testroot/stdout.expected echo "2) $short_commit1 $d1 $GOT_AUTHOR_8 A" >> $testroot/stdout.expected echo "3) $short_commit1 $d1 $GOT_AUTHOR_8 B" >> $testroot/stdout.expected @@ -1042,7 +1042,7 @@ test_blame_commit_keywords() { done local author_time=$(git_show_author_time "$repo") - local d=$(date -u -r $author_time +"%G-%m-%d") + local d=$(date -u -r $author_time +"%F") got blame -r "$repo" -c:head:-8 alpha > "$testroot/stdout" echo "1) $(pop_idx 1 $@) $d $GOT_AUTHOR_8 alpha" > \ blob - 13dd31e4feec963e558e3e0eebbcfac22c15c741 blob + b0adfd36a468c7760119682e77e3c30152401592 --- regress/cmdline/histedit.sh +++ regress/cmdline/histedit.sh @@ -156,10 +156,10 @@ test_histedit_no_op() { # We should have a backup of old commits (cd $testroot/repo && got histedit -l > $testroot/stdout) - d_orig1=`date -u -r $old_author_time1 +"%G-%m-%d"` + d_orig1=`date -u -r $old_author_time1 +"%F"` d_orig2=`date -u -r $old_author_time2 +"%a %b %e %X %Y UTC"` - d_new2=`date -u -r $new_author_time2 +"%G-%m-%d"` - d_orig=`date -u -r $orig_author_time +"%G-%m-%d"` + d_new2=`date -u -r $new_author_time2 +"%F"` + d_orig=`date -u -r $orig_author_time +"%F"` cat > $testroot/stdout.expected < /dev/null) local commit_id2=`git_show_head $testroot/repo` local author_time2=`git_show_author_time $testroot/repo` - d=`date -u -r $author_time1 +"%G-%m-%d"` + d=`date -u -r $author_time1 +"%F"` printf "$d %-7s test oneline\n" master > $testroot/stdout.expected - d=`date -u -r $author_time2 +"%G-%m-%d"` + d=`date -u -r $author_time2 +"%F"` printf "$d %.7s test oneline\n" $commit_id1 >> $testroot/stdout.expected (cd $testroot/repo && got log -s | head -n 2 > $testroot/stdout) @@ -963,7 +963,7 @@ EOF test_log_commit_keywords() { local testroot=$(test_init log_commit_keywords) local commit_time=`git_show_author_time $testroot/repo` - local d=`date -u -r $commit_time +"%G-%m-%d"` + local d=`date -u -r $commit_time +"%F"` set -- "$(git_show_head $testroot/repo)" @@ -1280,11 +1280,11 @@ test_log_toposort() { local short_commit2=`trim_obj_id 33 $commit2` local short_commit3=`trim_obj_id 33 $commit3` - d_0=`date -u -r $author_time0 +"%G-%m-%d"` - d_1=`date -u -r $author_time1 +"%G-%m-%d"` - d_2=`date -u -r $author_time2 +"%G-%m-%d"` - d_3=`date -u -r $author_time3 +"%G-%m-%d"` - d_m=`date -u -r $merge_time +"%G-%m-%d"` + d_0=`date -u -r $author_time0 +"%F"` + d_1=`date -u -r $author_time1 +"%F"` + d_2=`date -u -r $author_time2 +"%F"` + d_3=`date -u -r $author_time3 +"%F"` + d_m=`date -u -r $merge_time +"%F"` got log -r $testroot/repo -s -b -t > $testroot/stdout cat > $testroot/stdout.expected < $testroot/stdout) d_orig2=`date -u -r $orig_author_time2 +"%a %b %e %X %Y UTC"` - d_new2=`date -u -r $new_author_time2 +"%G-%m-%d"` - d_0=`date -u -r $commit0_author_time +"%G-%m-%d"` + d_new2=`date -u -r $new_author_time2 +"%F"` + d_0=`date -u -r $commit0_author_time +"%F"` cat > $testroot/stdout.expected < /dev/null) local commit_id4=`git_show_head $testroot/repo` local author_time=`git_show_author_time $testroot/repo` - local ymd=`date -u -r $author_time +"%G-%m-%d"` + local ymd=`date -u -r $author_time +"%F"` cat <$TOG_TEST_SCRIPT WAIT_FOR_UI wait for blame to finish @@ -83,7 +83,7 @@ test_blame_commit_keywords() local wt="$testroot/wt" local id=$(git_show_head "$repo") local author_time=$(git_show_author_time "$repo") - local ymd=$(date -u -r $author_time +"%G-%m-%d") + local ymd=$(date -u -r $author_time +"%F") set -- "$id" @@ -168,7 +168,7 @@ test_blame_commit_keywords() done author_time=$(git_show_author_time "$repo") - ymd=$(date -u -r $author_time +"%G-%m-%d") + ymd=$(date -u -r $author_time +"%F") # :base:- keyword in work tree cat <<-EOF >$testroot/view.expected blob - bc8e1f86537b6f5d928c84cdd4144af824835317 blob + aca1f106300cbd9e2079fa5bedad94acb5af6f36 --- regress/tog/log.sh +++ regress/tog/log.sh @@ -23,7 +23,7 @@ test_log_hsplit_diff() local head_id=`git_show_head $testroot/repo` local author_time=`git_show_author_time $testroot/repo` local date=`date -u -r $author_time +"%a %b %e %X %Y UTC"` - local ymd=`date -u -r $author_time +"%G-%m-%d"` + local ymd=`date -u -r $author_time +"%F"` cat <$TOG_TEST_SCRIPT KEY_ENTER open diff view of selected commit @@ -78,7 +78,7 @@ test_log_vsplit_diff() local head_id=`git_show_head $testroot/repo` local author_time=`git_show_author_time $testroot/repo` local date=`date -u -r $author_time +"%a %b %e %X %Y UTC"` - local ymd=`date -u -r $author_time +"%G-%m-%d"` + local ymd=`date -u -r $author_time +"%F"` local blobid_alpha=`get_blob_id $testroot/repo "" alpha` local blobid_beta=`get_blob_id $testroot/repo "" beta` @@ -134,7 +134,7 @@ test_log_show_author() local head_id=`git_show_head $testroot/repo` local author_time=`git_show_author_time $testroot/repo` local date=`date -u -r $author_time +"%a %b %e %X %Y UTC"` - local ymd=`date -u -r $author_time +"%G-%m-%d"` + local ymd=`date -u -r $author_time +"%F"` local head_id_len8=`trim_obj_id 32 $head_id` echo "mod alpha" > $testroot/repo/alpha @@ -177,7 +177,7 @@ test_log_scroll_right() local head_id=`git_show_head $testroot/repo` local author_time=`git_show_author_time $testroot/repo` local date=`date -u -r $author_time +"%a %b %e %X %Y UTC"` - local ymd=`date -u -r $author_time +"%G-%m-%d"` + local ymd=`date -u -r $author_time +"%F"` local msg="scroll this log message to the right four characters" local scrolled_msg="ter] scroll this log message to the right four character" @@ -217,7 +217,7 @@ test_log_hsplit_ref() local head_id=`git_show_head $testroot/repo` local author_time=`git_show_author_time $testroot/repo` local date=`date -u -r $author_time +"%a %b %e %X %Y UTC"` - local ymd=`date -u -r $author_time +"%G-%m-%d"` + local ymd=`date -u -r $author_time +"%F"` cat <$TOG_TEST_SCRIPT R open ref view @@ -258,7 +258,7 @@ test_log_hsplit_tree() local head_id=`git_show_head $testroot/repo` local author_time=`git_show_author_time $testroot/repo` local date=`date -u -r $author_time +"%a %b %e %X %Y UTC"` - local ymd=`date -u -r $author_time +"%G-%m-%d"` + local ymd=`date -u -r $author_time +"%F"` cat <$TOG_TEST_SCRIPT T open tree view @@ -361,7 +361,7 @@ test_log_commit_keywords() local wt="$testroot/wt" local id=$(git_show_head "$repo") local author_time=$(git_show_author_time "$repo") - local ymd=$(date -u -r $author_time +"%G-%m-%d") + local ymd=$(date -u -r $author_time +"%F") set -- "$id" @@ -519,7 +519,7 @@ test_log_show_base_commit() local head_id=$(git_show_head "$repo") local author_time=$(git_show_author_time "$repo") - local ymd=$(date -u -r "$author_time" +"%G-%m-%d") + local ymd=$(date -u -r "$author_time" +"%F") # check up-to-date base commit marker prefixes base commit log message cat <<-EOF >$TOG_TEST_SCRIPT @@ -638,7 +638,7 @@ test_log_limit_view() return 1 fi local author_time=$(git_show_author_time "$repo") - local ymd=$(date -u -r $author_time +"%G-%m-%d") + local ymd=$(date -u -r $author_time +"%F") local id=$(git_show_head "$repo") # check base commit marker is not drawn @@ -698,7 +698,7 @@ test_log_search() done local author_time=$(git_show_author_time "$repo") - local ymd=$(date -u -r $author_time +"%G-%m-%d") + local ymd=$(date -u -r $author_time +"%F") cat <<-EOF >$TOG_TEST_SCRIPT /alpha commit 8 blob - 49be7dc0e431407602c4dba0ac7030028d5a567e blob + ef69429eb4ba2e561f99ebcf790e0f123f4d05cb --- tog/tog.c +++ tog/tog.c @@ -2459,7 +2459,7 @@ draw_commit(struct tog_view *view, struct commit_queue committer_time = got_object_commit_get_committer_time(commit); if (gmtime_r(&committer_time, &tm) == NULL) return got_error_from_errno("gmtime_r"); - if (strftime(datebuf, sizeof(datebuf), "%G-%m-%d ", &tm) == 0) + if (strftime(datebuf, sizeof(datebuf), "%F ", &tm) == 0) return got_error(GOT_ERR_NO_SPACE); if (avail <= date_display_cols) @@ -8790,7 +8790,7 @@ show_ref_view(struct tog_view *view) free(id); if (gmtime_r(&t, &tm) == NULL) return got_error_from_errno("gmtime_r"); - if (strftime(ymd, sizeof(ymd), "%G-%m-%d ", &tm) == 0) + if (strftime(ymd, sizeof(ymd), "%F ", &tm) == 0) return got_error(GOT_ERR_NO_SPACE); } if (got_ref_is_symbolic(re->ref)) {