Skip to content

Commit 15daf6d

Browse files
authored
RFC date: omit day for RFC (#216)
When the series' name is RFC omit the day in the data. Unless it's a April 1st, then they do have a day. Actually check is for 'RFC', left comment that this sounds fragile. Signed-off-by: Miek Gieben <[email protected]>
1 parent c915b8d commit 15daf6d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

render/xml/title.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (r *Renderer) titleBlock(w io.Writer, t *mast.Title) {
8989
r.TitleAuthor(w, author, "author")
9090
}
9191

92-
r.TitleDate(w, d.Date)
92+
r.TitleDate(w, d.Date, d.SeriesInfo)
9393

9494
r.outTagContent(w, "<area", d.Area)
9595

@@ -175,7 +175,7 @@ func (r *Renderer) TitleAuthor(w io.Writer, a mast.Author, tag string) {
175175
}
176176

177177
// TitleDate outputs the date from the TOML title block.
178-
func (r *Renderer) TitleDate(w io.Writer, d time.Time) {
178+
func (r *Renderer) TitleDate(w io.Writer, d time.Time, s reference.SeriesInfo) {
179179
if d.IsZero() { // not specified
180180
r.outs(w, "<date/>\n")
181181
return
@@ -188,9 +188,16 @@ func (r *Renderer) TitleDate(w io.Writer, d time.Time) {
188188
if d.Month() > 0 {
189189
attr = append(attr, d.Format("month=\"January\""))
190190
}
191-
if x := d.Day(); x > 0 {
192-
attr = append(attr, fmt.Sprintf(`day="%d"`, x))
191+
if s.Name != "RFC" { // or just check for Internet-Draft ??
192+
if x := d.Day(); x > 0 {
193+
attr = append(attr, fmt.Sprintf(`day="%d"`, x))
194+
}
195+
}
196+
// April 1st RFCs, do have a 'day'
197+
if s.Name == "RFC" && d.Month() == time.April && d.Day() == 1 {
198+
attr = append(attr, fmt.Sprintf(`day="%d"`, d.Day()))
193199
}
200+
194201
r.outTag(w, "<date", attr)
195202
r.outs(w, "</date>\n")
196203
}

0 commit comments

Comments
 (0)