Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
de36d19d
Commit
de36d19d
authored
Jun 30, 2011
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time: zero-pad two-digit years.
Fixes #2024 R=adg, dsymonds CC=golang-dev
https://golang.org/cl/4635083
parent
ba8e61d8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
format.go
src/pkg/time/format.go
+1
-1
time_test.go
src/pkg/time/time_test.go
+9
-8
No files found.
src/pkg/time/format.go
View file @
de36d19d
...
...
@@ -248,7 +248,7 @@ func (t *Time) Format(layout string) string {
var
p
string
switch
std
{
case
stdYear
:
p
=
strconv
.
Itoa64
(
t
.
Year
%
100
)
p
=
zeroPad
(
int
(
t
.
Year
%
100
)
)
case
stdLongYear
:
p
=
strconv
.
Itoa64
(
t
.
Year
)
case
stdMonth
:
...
...
src/pkg/time/time_test.go
View file @
de36d19d
...
...
@@ -142,21 +142,22 @@ type FormatTest struct {
}
var
formatTests
=
[]
FormatTest
{
{
"ANSIC"
,
ANSIC
,
"
Thu Feb 4 21:00:57 2010
"
},
{
"UnixDate"
,
UnixDate
,
"
Thu Feb 4 21:00:57 PST 2010
"
},
{
"RubyDate"
,
RubyDate
,
"
Thu Feb 04 21:00:57 -0800 2010
"
},
{
"RFC822"
,
RFC822
,
"04 Feb
10
2100 PST"
},
{
"RFC850"
,
RFC850
,
"
Thursday, 04-Feb-10
21:00:57 PST"
},
{
"RFC1123"
,
RFC1123
,
"
Thu, 04 Feb 2010
21:00:57 PST"
},
{
"RFC3339"
,
RFC3339
,
"20
10
-02-04T21:00:57-08:00"
},
{
"ANSIC"
,
ANSIC
,
"
Wed Feb 4 21:00:57 2009
"
},
{
"UnixDate"
,
UnixDate
,
"
Wed Feb 4 21:00:57 PST 2009
"
},
{
"RubyDate"
,
RubyDate
,
"
Wed Feb 04 21:00:57 -0800 2009
"
},
{
"RFC822"
,
RFC822
,
"04 Feb
09
2100 PST"
},
{
"RFC850"
,
RFC850
,
"
Wednesday, 04-Feb-09
21:00:57 PST"
},
{
"RFC1123"
,
RFC1123
,
"
Wed, 04 Feb 2009
21:00:57 PST"
},
{
"RFC3339"
,
RFC3339
,
"20
09
-02-04T21:00:57-08:00"
},
{
"Kitchen"
,
Kitchen
,
"9:00PM"
},
{
"am/pm"
,
"3pm"
,
"9pm"
},
{
"AM/PM"
,
"3PM"
,
"9PM"
},
{
"two-digit year"
,
"06 01 02"
,
"09 02 04"
},
}
func
TestFormat
(
t
*
testing
.
T
)
{
// The numeric time represents Thu Feb 4 21:00:57 PST 2010
time
:=
SecondsToLocalTime
(
12
65346
057
)
time
:=
SecondsToLocalTime
(
12
33810
057
)
for
_
,
test
:=
range
formatTests
{
result
:=
time
.
Format
(
test
.
format
)
if
result
!=
test
.
result
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment