Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/text: support ordinal suffix in time format #8301

Closed
gopherbot opened this issue Jun 30, 2014 · 7 comments
Closed

x/text: support ordinal suffix in time format #8301

gopherbot opened this issue Jun 30, 2014 · 7 comments

Comments

@gopherbot
Copy link

by krolaw:

go version go1.3 darwin/amd64

I have a template with:
{{.Date.Format "Monday 2nd January 2006"}}

It displays: Tuesday 10nd June 2014
Instead of: Tuesday 10th June 2014

Thanks.
@cznic
Copy link
Contributor

cznic commented Jun 30, 2014

Comment 1:

I suggest to use any other mechanism (template func, feeding a plain func result) to
resolve this. Making the template package support/be aware of one specific language
conventions is IMO not a good approach.

@gopherbot
Copy link
Author

Comment 2 by krolaw:

Actually, this request has nothing to do with the templates package.  It's the time
package's Format function (.Date is a time.Time object).  I used the template example as
that was how I was calling it.
Perhaps I should have gone with:
fmt.Println(time.Date(2014,6,10,0,0,0,0,time.Local).Format("Monday 2nd January 2006"))
In terms of language conventions, the package does support days of the week, etc.

@ianlancetaylor
Copy link
Contributor

Comment 3:

This kind of thing varies widely by language.  The right place to support it in Go will
be in the go.text packages.  We don't want to try to cover every language in the time
package, and we don't want to just support one language there either.

Labels changed: added repo-text, release-none.

@bradfitz bradfitz removed the new label Dec 18, 2014
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc removed the release-none label Apr 10, 2015
@rsc rsc changed the title go.text: support ordinal suffix in time format x/text: support ordinal suffix in time format Apr 14, 2015
@rsc rsc modified the milestones: Unreleased, Unplanned Apr 14, 2015
@rsc rsc removed the repo-text label Apr 14, 2015
@usedbytes
Copy link

This kind of thing varies widely by language. The right place to support it in Go will
be in the go.text packages. We don't want to try to cover every language in the time
package, and we don't want to just support one language there either.

The time package's format functionality is already completely tied to English (see all the hardcoded English in nextStdChunk(): https://github.com/golang/go/blob/master/src/time/format.go#L120). This would be a useful addition without making the localisation situation any worse.
Are you saying a change which implements this in the time package wouldn't be welcome?

@gopherbot
Copy link
Author

CL https://golang.org/cl/16010 mentions this issue.

@ianlancetaylor
Copy link
Contributor

Yes, I think this change would not be welcome in the standard time package. Sorry.

@stemar94
Copy link

@usedbytes Maybe file a follow-up proposal issue for the change on the time package.
I would like to see some more discussion why or why not to add in order to achieve consensus for the problem. Only my opinion.

@golang golang locked and limited conversation to collaborators Oct 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants