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

Comments

Projects
None yet
3 participants
@gopherbot
Copy link

commented Dec 15, 2009

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

This comment has been minimized.

Copy link
Contributor

commented Dec 15, 2009

Comment 1:

go for it

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

Status changed to Accepted.

@gopherbot

This comment has been minimized.

Copy link
Author

commented Dec 15, 2009

Comment 2 by sionide21:

Will do.
@ajstarks

This comment has been minimized.

Copy link
Contributor

commented Dec 16, 2009

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

This comment has been minimized.

Copy link
Contributor

commented Dec 17, 2009

Comment 4:

This issue was closed by revision d2a835f.

Status changed to Fixed.

Merged into issue #-.

@gopherbot gopherbot added the fixed label Dec 17, 2009

@golang golang locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.