Skip to content

time: time.Parse() doesn't accept 2-char day abbreviations (bsd date output) #75576

@TLINDEN

Description

@TLINDEN

Go version

1.23.5

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/scip/.cache/go-build'
GOENV='/home/scip/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/scip/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/scip/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.5'
GODEBUG=''
GOTELEMETRY='off'
GOTELEMETRYDIR='/home/scip/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/scip/tmp/dateparse/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2370889587=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I wanted to parse FreeBSD's date(1) command output via ssh (I do not get this kind of output when logged in), which looks like this:

% ssh $some-freebsd-box date
Di. 23 Sep. 2025 23:39:13 CEST

I tried this code to parse it:

ts, err = time.Parse("Mo. 02 Jan. 2006 15:04:05 MST", timestamp)
if err != nil {
    log.Fatal(err)
}

What did you see happen?

This is the error I received:

parsing time "Di. 23 Sep. 2025 23:15:11 CEST" as "Mo. 02 Jan. 2006 15:04:05 MST": cannot parse "Di. 23 Sep. 2025 23:15:11 CEST" as "Mo. "

What did you expect to see?

I expected to retrieve a time.Time object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a tool

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions