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
93b8438e
Commit
93b8438e
authored
Oct 04, 2011
by
Paul Borman
Committed by
Rob Pike
Oct 04, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time: make month/day name comparisons case insenstive
Fixes #2324. R=r, r CC=golang-dev
https://golang.org/cl/5180044
parent
e2d326b8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
format.go
src/pkg/time/format.go
+19
-1
time_test.go
src/pkg/time/time_test.go
+3
-0
No files found.
src/pkg/time/format.go
View file @
93b8438e
...
@@ -232,9 +232,27 @@ var longMonthNames = []string{
...
@@ -232,9 +232,27 @@ var longMonthNames = []string{
"December"
,
"December"
,
}
}
// match returns true if s1 and s2 match ignoring case.
// It is assumed s1 and s2 are the same length.
func
match
(
s1
,
s2
string
)
bool
{
for
i
:=
0
;
i
<
len
(
s1
);
i
++
{
c1
:=
s1
[
i
]
c2
:=
s2
[
i
]
if
c1
!=
c2
{
// Switch to lower-case; 'a'-'A' is known to be a single bit.
c1
|=
'a'
-
'A'
c2
|=
'a'
-
'A'
if
c1
!=
c2
||
c1
<
'a'
||
c1
>
'z'
{
return
false
}
}
}
return
true
}
func
lookup
(
tab
[]
string
,
val
string
)
(
int
,
string
,
os
.
Error
)
{
func
lookup
(
tab
[]
string
,
val
string
)
(
int
,
string
,
os
.
Error
)
{
for
i
,
v
:=
range
tab
{
for
i
,
v
:=
range
tab
{
if
len
(
val
)
>=
len
(
v
)
&&
val
[
0
:
len
(
v
)]
==
v
{
if
len
(
val
)
>=
len
(
v
)
&&
match
(
val
[
0
:
len
(
v
)],
v
)
{
return
i
,
val
[
len
(
v
)
:
],
nil
return
i
,
val
[
len
(
v
)
:
],
nil
}
}
}
}
...
...
src/pkg/time/time_test.go
View file @
93b8438e
...
@@ -252,6 +252,9 @@ var parseTests = []ParseTest{
...
@@ -252,6 +252,9 @@ var parseTests = []ParseTest{
// Amount of white space should not matter.
// Amount of white space should not matter.
{
"ANSIC"
,
ANSIC
,
"Thu Feb 4 21:00:57 2010"
,
false
,
true
,
1
,
0
},
{
"ANSIC"
,
ANSIC
,
"Thu Feb 4 21:00:57 2010"
,
false
,
true
,
1
,
0
},
{
"ANSIC"
,
ANSIC
,
"Thu Feb 4 21:00:57 2010"
,
false
,
true
,
1
,
0
},
{
"ANSIC"
,
ANSIC
,
"Thu Feb 4 21:00:57 2010"
,
false
,
true
,
1
,
0
},
// Case should not matter
{
"ANSIC"
,
ANSIC
,
"THU FEB 4 21:00:57 2010"
,
false
,
true
,
1
,
0
},
{
"ANSIC"
,
ANSIC
,
"thu feb 4 21:00:57 2010"
,
false
,
true
,
1
,
0
},
// Fractional seconds.
// Fractional seconds.
{
"millisecond"
,
"Mon Jan _2 15:04:05.000 2006"
,
"Thu Feb 4 21:00:57.012 2010"
,
false
,
true
,
1
,
3
},
{
"millisecond"
,
"Mon Jan _2 15:04:05.000 2006"
,
"Thu Feb 4 21:00:57.012 2010"
,
false
,
true
,
1
,
3
},
{
"microsecond"
,
"Mon Jan _2 15:04:05.000000 2006"
,
"Thu Feb 4 21:00:57.012345 2010"
,
false
,
true
,
1
,
6
},
{
"microsecond"
,
"Mon Jan _2 15:04:05.000000 2006"
,
"Thu Feb 4 21:00:57.012345 2010"
,
false
,
true
,
1
,
6
},
...
...
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