tuesday
Ruby-compatible Strftime function
About tuesday
Tuesday: Ruby-Compatible Strftime for Go
Tuesday formats Go time.Time values with Ruby-compatible strftime format
strings. It supports padding and case flags, field widths, fractional seconds,
epoch time, and colon-delimited timezone offsets.
Tuesday was developed for use by Liquid and Gojekyll.
Install
go get github.com/osteele/tuesday@latest
Usage
package main
import (
"fmt"
"time"
"github.com/osteele/tuesday"
)
func main() {
value := time.Date(2026, 8, 11, 15, 4, 5, 123456789, time.UTC)
formatted, err := tuesday.Strftime("%Y-%m-%d %H:%M:%S.%3N %:z", value)
if err != nil {
panic(err)
}
fmt.Println(formatted)
}
Output:
2026-08-11 15:04:05.123 +00:00
Compile formats that are used repeatedly. A compiled formatter is immutable and safe for concurrent use:
formatter, err := tuesday.Compile("%a, %b %d, %Y")
if err != nil {
panic(err)
}
formatted := formatter.Format(value)
Compatibility
Tuesday targets the formatting behavior of Ruby 3.4
Time#strftime. Its differential
test matrix also uses DateTime#strftime for %Q, which Ruby Time does not
implement. Tuesday additionally supports %+ as an extension; Ruby Time
does not implement %+, while Ruby DateTime prints the UTC offset rather
than the location name.
- Month and weekday names use Go's English names, corresponding to Ruby's C
locale. Locale-specific names are not supported;
EandOmodifiers use the corresponding unmodified conversion. %Zuses the name attached to the Gotime.Location. A numeric offset alone does not imply a timezone abbreviation.- Unsupported directives are copied to the result unchanged.
- Supported field widths greater than 1 MiB return an error to prevent excessive allocation.
%Q,%N,%L,%:z,%::z, and%:::zfollow the corresponding RubyDateTime, fractional-second, and timezone conventions.
The Ruby differential test is skipped when Ruby is unavailable. The checked-in Go tests remain sufficient to run the package test suite without Ruby.
Development
go test ./...
go test -fuzz=FuzzStrftime
go test -bench=. -benchmem
References
License
MIT License
Frequently Asked Questions
What is tuesday?
tuesday is a Date and Time library for the Go programming language. Ruby-compatible Strftime function
How do I install tuesday?
Install tuesday with the Go module system using `go get osteele/tuesday`. Check the repository for the current installation instructions.
What category does tuesday belong to?
tuesday is listed under Date and Time, specifically Date and Time.