-
Notifications
You must be signed in to change notification settings - Fork 18k
Implement strftime #444
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
Labels
Comments
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 [email protected]. |
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') |
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? |
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. |
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 issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by sionide21:
The text was updated successfully, but these errors were encountered: