11package strftime
22
33import (
4+ "bytes"
5+ "fmt"
6+ "io"
47 "strconv"
58 "strings"
69 "time"
@@ -61,7 +64,7 @@ type Appender interface {
6164 Append ([]byte , time.Time ) []byte
6265}
6366
64- // AppendFunc is an utility type to allow users to create a
67+ // AppendFunc is an utility type to allow users to create a
6568// function-only version of an Appender
6669type AppendFunc func ([]byte , time.Time ) []byte
6770
@@ -71,6 +74,27 @@ func (af AppendFunc) Append(b []byte, t time.Time) []byte {
7174
7275type appenderList []Appender
7376
77+ type dumper interface {
78+ dump (io.Writer )
79+ }
80+
81+ func (l appenderList ) dump (out io.Writer ) {
82+ var buf bytes.Buffer
83+ ll := len (l )
84+ for i , a := range l {
85+ if dumper , ok := a .(dumper ); ok {
86+ dumper .dump (& buf )
87+ } else {
88+ fmt .Fprintf (& buf , "%#v" , a )
89+ }
90+
91+ if i < ll - 1 {
92+ fmt .Fprintf (& buf , ",\n " )
93+ }
94+ }
95+ buf .WriteTo (out )
96+ }
97+
7498// does the time.Format thing
7599type stdlibFormat struct {
76100 s string
@@ -104,6 +128,10 @@ func (v stdlibFormat) combine(w combiner) Appender {
104128 return StdlibFormat (v .s + w .str ())
105129}
106130
131+ func (v stdlibFormat ) dump (out io.Writer ) {
132+ fmt .Fprintf (out , "stdlib: %s" , v .s )
133+ }
134+
107135type verbatimw struct {
108136 s string
109137}
@@ -135,6 +163,10 @@ func (v verbatimw) str() string {
135163 return v .s
136164}
137165
166+ func (v verbatimw ) dump (out io.Writer ) {
167+ fmt .Fprintf (out , "verbatim: %s" , v .s )
168+ }
169+
138170// These words below, as well as any decimal character
139171var combineExclusion = []string {
140172 "Mon" ,
0 commit comments