]> Sergey Matveev's repositories - sgblog.git/blobdiff - cmd/sgblog/http.go
Shorter datetimes displaying
[sgblog.git] / cmd / sgblog / http.go
index 18477a6c53fa6b7c81159a040daae8e067247125..968555826bba8621a28e59578b0b859e6b626359 100644 (file)
@@ -35,6 +35,7 @@ import (
        "os"
        "strconv"
        "strings"
+       "time"
 
        "github.com/hjson/hjson-go"
        "go.stargrave.org/sgblog"
@@ -300,7 +301,18 @@ func serveHTTP() {
                                `<th size="5%"><a title="Lines">L</a></th>` +
                                `<th size="5%"><a title="Comments">C</a></th>` +
                                "<th>Linked to</th></tr>\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(
+                                       "<tr><td colspan=6><center><tt>%04d-%02d-%02d</tt></center></td></tr>\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 = "&nbsp;"
                        }
                        table.WriteString(fmt.Sprintf(
-                               "<tr><td>%d</td><td><tt>%s</tt></td>"+
+                               "<tr><td>%d</td><td><tt>%02d:%02d</tt></td>"+
                                        "<td>%s</td>"+
                                        "<td>%d</td><td>%s</td>"+
                                        "<td>%s</td></tr>\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,