From: Sergey Matveev Date: Sat, 14 Mar 2020 11:33:55 +0000 (+0300) Subject: Shorter datetimes displaying X-Git-Tag: v0.4.0~4 X-Git-Url: http://www.git.stargrave.org/?p=sgblog.git;a=commitdiff_plain;h=f39628f13e14ba3ba94072c1cd4f747aa90228a1 Shorter datetimes displaying --- diff --git a/cmd/sgblog/gopher.go b/cmd/sgblog/gopher.go index 808c40f..e98d65b 100644 --- a/cmd/sgblog/gopher.go +++ b/cmd/sgblog/gopher.go @@ -30,6 +30,7 @@ import ( "os" "strconv" "strings" + "time" "github.com/hjson/hjson-go" "go.stargrave.org/sgblog" @@ -95,22 +96,33 @@ func serveGopher() { logEnded := false var menu bytes.Buffer + var yearPrev int + var monthPrev time.Month + var dayPrev int for i := 0; i < PageEntries; i++ { commit, err := repoLog.Next() if err != nil { logEnded = true break } + yearCur, monthCur, dayCur := commit.Author.When.Date() + if dayCur != dayPrev || monthCur != monthPrev || yearCur != yearPrev { + menu.WriteString(fmt.Sprintf( + "i%04d-%02d-%02d\t\tnull.host\t1%s", + yearCur, monthCur, dayCur, CRLF, + )) + yearPrev, monthPrev, dayPrev = yearCur, monthCur, dayCur + } commitN++ lines := msgSplit(commit.Message) - var commentsValue string if l := len(parseComments(getNote(commentsTree, commit.Hash))); l > 0 { commentsValue = fmt.Sprintf(" (%dC)", l) } menu.WriteString(fmt.Sprintf( - "0[%s] %s (%dL)%s\t/%s\t%s\t%d%s", - commit.Author.When.Format(sgblog.WhenFmt), + "0[%02d:%02d] %s (%dL)%s\t/%s\t%s\t%d%s", + commit.Author.When.Hour(), + commit.Author.When.Minute(), lines[0], len(lines)-2, commentsValue, diff --git a/cmd/sgblog/http.go b/cmd/sgblog/http.go index 18477a6..9685558 100644 --- a/cmd/sgblog/http.go +++ b/cmd/sgblog/http.go @@ -35,6 +35,7 @@ import ( "os" "strconv" "strings" + "time" "github.com/hjson/hjson-go" "go.stargrave.org/sgblog" @@ -300,7 +301,18 @@ func serveHTTP() { `L` + `C` + "Linked to\n") + var yearPrev int + var monthPrev time.Month + var dayPrev int for _, entry := range entries { + yearCur, monthCur, dayCur := entry.commit.Author.When.Date() + if dayCur != dayPrev || monthCur != monthPrev || yearCur != yearPrev { + table.WriteString(fmt.Sprintf( + "
%04d-%02d-%02d
\n", + yearCur, monthCur, dayCur, + )) + yearPrev, monthPrev, dayPrev = yearCur, monthCur, dayCur + } commitN++ lines := msgSplit(entry.commit.Message) domains := []string{} @@ -318,11 +330,13 @@ func serveHTTP() { commentsValue = " " } table.WriteString(fmt.Sprintf( - "%d%s"+ + "%d%02d:%02d"+ "%s"+ "%d%s"+ "%s\n", - commitN, entry.commit.Author.When.Format(sgblog.WhenFmt), + commitN, + entry.commit.Author.When.Hour(), + entry.commit.Author.When.Minute(), makeA(cfg.URLPrefix+"/"+entry.commit.Hash.String(), lines[0]), len(lines)-2, commentsValue, diff --git a/common.go b/common.go index f778860..de17393 100644 --- a/common.go +++ b/common.go @@ -2,6 +2,6 @@ package sgblog const ( + Version = "0.4.0" WhenFmt = "2006-01-02 15:04:05Z07:00" - Version = "0.3.5" )