Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upproposal: time: Long/Short day and month names should start with Upper case to allow customization #34698
Comments
This comment has been minimized.
This comment has been minimized.
This is an API change, so I turned it into a proposal. Personally I think this is simply beyond the scope of the time package. The time package provides simple functionality, using some English words, with no support for internationalization. Serious internationalization support should be done using a different package, such as https://godoc.org/gitlab.com/variadico/lctime (note that I have never tried that package myself and I don't know its quality). |
This comment has been minimized.
This comment has been minimized.
Yes, this is definitely beyond the scope of the time package. |
This comment has been minimized.
This comment has been minimized.
There's already an answer (use x/text/date), and the suggested approach is not safe for use by multiple goroutines: what if you have a server that wants to format dates differently in different requests? Modifying globals is not safe there. This seems like a likely decline (unsafe, functionality started elsewhere). Leaving open for a week for final comments. |
This comment has been minimized.
This comment has been minimized.
No change in consensus, so declining. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I am developing a web app that should support multiple languages (days and months names should also change when user selects a languag). I am using "github.com/beego/i18n" to achieve i18n on my front-end. All days and months (long and short names) are configured for each language in the locale.ini specified for that language. Even when I read the days and months for each language, I am not able to pass it so the time module uses it instead of the hard-coded English long/short days and months names.
Suggesting
var longDayNames
var shortDayNames
var shortMonthNames
var longMonthNames
be changed to
var ShortDayNames
var LongDayNames
var ShortMonthNames
var LongMonthNames
func (c *ExtendedController) UpdateDaysAndMonthsToUserLocale() {
}
What did you expect to see?
var LongDayNames = []string{ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", }
var ShortDayNames = []string{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", }
var ShortMonthNames = []string{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", }
var LongMonthNames = []string{ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", }
What did you see instead?
var longDayNames = []string{ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", }
var shortDayNames = []string{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", }
var shortMonthNames = []string{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", }
var longMonthNames = []string{ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", }