Skip to content

need time.Strftime #8390

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

Closed
gopherbot opened this issue Jul 18, 2014 · 6 comments
Closed

need time.Strftime #8390

gopherbot opened this issue Jul 18, 2014 · 6 comments

Comments

@gopherbot
Copy link
Contributor

by crquan:

I want to reopen Issue #444:   Implement strftime

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 and C and Python, I hope this can be available in
Go as well, the date command exists in Unix for decades, the strftime in C library for
decades, why Go language not willing to provide the same convenience?

Shell:  date '+%Y%m%d-%H%M%S'
Python: time.strftime('%Y%m%d-%H%M%S')
C:      strftime(buf, sizeof buf, '%Y%m%d-%H%M%S', tm)



there mentioned time.Format, but it is buggy actually 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 that?

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?


I want to know if there's nobody doing a time.Strftime in golang community ? (in such
case, I am willing to contribute one)

Or is it because you guys won't accept it into standard time package?
(in such case, what can I say?)
@bradfitz
Copy link
Contributor

Comment 1:

Please don't re-open bugs that were already closed just because you disagree.
You're welcome to implement your own stftime or use one of the existing ones:
http://godoc.org/?q=strftime

Status changed to WorkingAsIntended.

@gopherbot
Copy link
Contributor Author

Comment 2 by crquan:

ok, so some of 3rd party implementations exist, but I am asking why don't you accept
strftime into standard time package? but accepted time.Format such a buggy and
inefficient function? what's the logic behind that?

@gopherbot
Copy link
Contributor Author

Comment 3 by crquan:

time.Format might be only useful to the Western world, but I mean it's generally buggy
and useless and inefficient, why did you accept that?

@bradfitz
Copy link
Contributor

Comment 4:

Labels changed: added restrict-addissuecomment-commit.

@bradfitz
Copy link
Contributor

Comment 5:

I closed comments here like issue #444, which contains the answers to OP's confusion.
Please use golang-nuts@ when learning the language and standard library. Don't file bugs.

@minux
Copy link
Member

minux commented Jul 18, 2014

Comment 6:

the layout string is wrong. please read the docs before saying something is broken.
thanks.
http://play.golang.org/p/iQi7JZZ40j

@golang golang locked and limited conversation to collaborators Dec 8, 2014
This issue was closed.
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

3 participants