Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gosqlite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gosqlite
Commits
d36a1dad
Commit
d36a1dad
authored
May 14, 2013
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test scanning null time.
parent
ea526be7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
date.go
date.go
+3
-3
date_test.go
date_test.go
+13
-1
No files found.
date.go
View file @
d36a1dad
...
...
@@ -43,7 +43,7 @@ type UnixTime time.Time
func
(
t
*
UnixTime
)
Scan
(
src
interface
{})
error
{
if
src
==
nil
{
t
=
nil
//
t = nil
return
nil
}
else
if
unixepoch
,
ok
:=
src
.
(
int64
);
ok
{
*
t
=
UnixTime
(
time
.
Unix
(
unixepoch
,
0
))
// local time
...
...
@@ -63,7 +63,7 @@ type JulianTime time.Time
func
(
t
*
JulianTime
)
Scan
(
src
interface
{})
error
{
if
src
==
nil
{
t
=
nil
//
t = nil
return
nil
}
else
if
jd
,
ok
:=
src
.
(
float64
);
ok
{
*
t
=
JulianTime
(
JulianDayToLocalTime
(
jd
))
// local time
...
...
@@ -83,7 +83,7 @@ type TimeStamp time.Time
func
(
t
*
TimeStamp
)
Scan
(
src
interface
{})
error
{
if
src
==
nil
{
t
=
nil
//
t = nil
return
nil
}
else
if
txt
,
ok
:=
src
.
(
string
);
ok
{
v
,
err
:=
time
.
Parse
(
"2006-01-02T15:04:05.999Z07:00"
,
txt
)
...
...
date_test.go
View file @
d36a1dad
...
...
@@ -33,7 +33,7 @@ func TestBindTime(t *testing.T) {
}
}
func
TestScan
(
t
*
testing
.
T
)
{
func
TestScan
Time
(
t
*
testing
.
T
)
{
db
:=
open
(
t
)
defer
checkClose
(
db
,
t
)
var
dt
time
.
Time
...
...
@@ -72,6 +72,18 @@ func TestScan(t *testing.T) {
}
}
func
TestScanNullTime
(
t
*
testing
.
T
)
{
db
:=
open
(
t
)
defer
checkClose
(
db
,
t
)
var
unix
UnixTime
err
:=
db
.
OneValue
(
"SELECT NULL"
,
&
unix
)
checkNoError
(
t
,
err
,
"Error scanning null time: %#v"
)
if
!
(
time
.
Time
)(
unix
)
.
IsZero
()
{
t
.
Error
(
"Expected zero time"
)
}
}
func
TestBindTimeAsString
(
t
*
testing
.
T
)
{
db
:=
open
(
t
)
defer
checkClose
(
db
,
t
)
...
...
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