Format formats d as a string.
(buf *bytes.Buffer)
| 168 | |
| 169 | // Format formats d as a string. |
| 170 | func (d Date) Format(buf *bytes.Buffer) { |
| 171 | switch d.days { |
| 172 | case math.MinInt32: |
| 173 | buf.WriteString("-infinity") |
| 174 | case math.MaxInt32: |
| 175 | buf.WriteString("infinity") |
| 176 | default: |
| 177 | // ToTime only returns an error on infinity, which was already checked above. |
| 178 | t, _ := d.ToTime() |
| 179 | year, month, day := t.Date() |
| 180 | bc := year <= 0 |
| 181 | if bc { |
| 182 | year = -year + 1 |
| 183 | } |
| 184 | fmt.Fprintf(buf, "%04d-%02d-%02d", year, month, day) |
| 185 | if bc { |
| 186 | buf.WriteString(" BC") |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | func (d Date) String() string { |
| 192 | var buf bytes.Buffer |
no test coverage detected