Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement strftime #444
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
rsc
Dec 21, 2009
Contributor
Strftime is a kitchen sink, a bad interface: no one remembers all the letters, so the only way to use it is with documentation in hand. At that point you might as well write the longer but more readable fmt.Sprintf equivalent. I intentionally hid time.format in favor of a small collection of commonly-used time formats. If there is a missing format, I'd rather add it than expose time.format.
Owner changed to r...@golang.org.
Strftime is a kitchen sink, a bad interface: no one remembers all the letters, so the only way to use it is with documentation in hand. At that point you might as well write the longer but more readable fmt.Sprintf equivalent. I intentionally hid time.format in favor of a small collection of commonly-used time formats. If there is a missing format, I'd rather add it than expose time.format. Owner changed to r...@golang.org. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
gopherbot
commented
Dec 22, 2009
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
gopherbot
Jul 18, 2014
no, I don't agree strftime is bad, it actually provides same way as date command, then
it's easier to write code as same as shell (call date) and python, I hope this can be
available in Go as well, the date command exists in Unix for decades, why Go language
not willing to provide the same convenience?
date '+%Y%m%d-%H%M%S'
time.strftime('%Y%m%d-%H%M%S')
gopherbot
commented
Jul 18, 2014
no, I don't agree strftime is bad, it actually provides same way as date command, then
it's easier to write code as same as shell (call date) and python, I hope this can be
available in Go as well, the date command exists in Unix for decades, why Go language
not willing to provide the same convenience?
date '+%Y%m%d-%H%M%S'
time.strftime('%Y%m%d-%H%M%S')
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
gopherbot
Jul 18, 2014
and the time.Format is buggy if I tried to use layout like this: (in Asia culture, we
don't assume people know the the months' English name, so we use all numbers)
const layout = "20140714-030001"
fmt.Println(time.Now().Format(layout))
it prints like 180730773-090007, what's the hell of this?
especially in logging functionality, I want to print current time in this format prepend
to every output line, I think the time.Format needs to guess what numbers mean in the
layout string every time, do you think is that efficient?
gopherbot
commented
Jul 18, 2014
and the time.Format is buggy if I tried to use layout like this: (in Asia culture, we
don't assume people know the the months' English name, so we use all numbers)
const layout = "20140714-030001"
fmt.Println(time.Now().Format(layout))
it prints like 180730773-090007, what's the hell of this?
especially in logging functionality, I want to print current time in this format prepend
to every output line, I think the time.Format needs to guess what numbers mean in the
layout string every time, do you think is that efficient?
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
robpike
Jul 18, 2014
Contributor
It's not buggy and your supposition is wrong. The layout is defined for a specific time, not any old time. This property is well explained in the documentation. The layout string you want is const layout = "20060102-150405" http://play.golang.org/p/tPjLQd4k14 The issue remains closed and perhaps should have comments disabled.
It's not buggy and your supposition is wrong. The layout is defined for a specific time, not any old time. This property is well explained in the documentation. The layout string you want is const layout = "20060102-150405" http://play.golang.org/p/tPjLQd4k14 The issue remains closed and perhaps should have comments disabled. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
robpike
Jul 18, 2014
Contributor
The package is not buggy, it works as explained in the documentation, using a format string that is set to a specific, standard time. Your layout string is wrong; use this: const layout = "20060102-150405" http://play.golang.org/p/tPjLQd4k14 The issue remains closed and should perhaps have comments disabled.
The package is not buggy, it works as explained in the documentation, using a format string that is set to a specific, standard time. Your layout string is wrong; use this: const layout = "20060102-150405" http://play.golang.org/p/tPjLQd4k14 The issue remains closed and should perhaps have comments disabled. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
gopherbot
added
workingasintended
labels
Jul 18, 2014
gopherbot
assigned
rsc
Jul 18, 2014
golang
locked and limited conversation to collaborators
Dec 8, 2014
gopherbot
added
the
FrozenDueToAge
label
Jun 24, 2016
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
gopherbot commentedDec 18, 2009
by sionide21: