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

time: add ISO 8601 format #431

Closed
gopherbot opened this issue Dec 15, 2009 · 4 comments
Closed

time: add ISO 8601 format #431

gopherbot opened this issue Dec 15, 2009 · 4 comments

Comments

@gopherbot
Copy link

by sionide21:

Currently there are three formats that `time.Time` will print in. I would
like to be able to also use ISO8601. I am willing to add this function
myself but was not sure of the workflow if no bug was present.
@rsc
Copy link
Contributor

rsc commented Dec 15, 2009

Comment 1:

go for it

Owner changed to r...@golang.org.

Status changed to Accepted.

@gopherbot
Copy link
Author

Comment 2 by sionide21:

Will do.

@ajstarks
Copy link
Contributor

Comment 3:

see attached file for what i've been working with;
in the style found in src/pkg/time.go the attached function could be:
func (t *Time)  ISO8601() string {
  var tz string;
  if t.Zone == "UTC" {
    tz = "Z";
  } else {
    tz = fmt.Sprintf("%03d00", t.ZoneOffset / 3600 )
  }
  return fmt.Sprintf("%04d-%02d-%02dT%02d:%02d:%02d%s", t.Year, t.Month, t.Day, t.Hour, t.Minute, 
t.Second, tz);
}
note that this uses fmt, not the stripped down format function found in time.go

Attachments:

  1. isofunctions.go (830 bytes)

@rsc
Copy link
Contributor

rsc commented Dec 17, 2009

Comment 4:

This issue was closed by revision d2a835f.

Status changed to Fixed.

Merged into issue #-.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
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