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
ddcc9654
Commit
ddcc9654
authored
Dec 01, 2011
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgrade to weekly release.
parent
b5ce2308
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
16 deletions
+16
-16
backup.go
backup.go
+1
-1
date.go
date.go
+11
-11
date_test.go
date_test.go
+4
-4
No files found.
backup.go
View file @
ddcc9654
...
...
@@ -74,7 +74,7 @@ func (b *Backup) Status() BackupStatus {
}
// Calls http://sqlite.org/c3ref/backup_finish.html#sqlite3backupstep, sqlite3_backup_remaining and sqlite3_backup_pagecount
func
(
b
*
Backup
)
Run
(
npage
int
,
sleepNs
int64
,
c
chan
<-
BackupStatus
)
error
{
func
(
b
*
Backup
)
Run
(
npage
int
,
sleepNs
time
.
Duration
,
c
chan
<-
BackupStatus
)
error
{
var
err
error
for
{
err
=
b
.
Step
(
npage
)
...
...
date.go
View file @
ddcc9654
...
...
@@ -11,25 +11,25 @@ import (
)
const
(
JULIAN_DAY
=
2440587.5
// 1970-01-01 00:00:00 is JD 2440587.5
DAY_IN_
NANOSECONDS
=
60
*
60
*
24
*
10E6
JULIAN_DAY
=
2440587.5
// 1970-01-01 00:00:00 is JD 2440587.5
DAY_IN_
SECONDS
=
60
*
60
*
24
)
func
JulianDayToUTC
(
jd
float64
)
*
time
.
Time
{
func
JulianDayToUTC
(
jd
float64
)
time
.
Time
{
jd
-=
JULIAN_DAY
jd
*=
DAY_IN_
NANO
SECONDS
return
time
.
NanosecondsToUTC
(
int64
(
jd
)
)
jd
*=
DAY_IN_SECONDS
return
time
.
Unix
(
int64
(
jd
),
0
)
.
UTC
(
)
}
func
JulianDayToLocalTime
(
jd
float64
)
*
time
.
Time
{
func
JulianDayToLocalTime
(
jd
float64
)
time
.
Time
{
jd
-=
JULIAN_DAY
jd
*=
DAY_IN_
NANO
SECONDS
return
time
.
NanosecondsToLocalTime
(
int64
(
jd
)
)
jd
*=
DAY_IN_SECONDS
return
time
.
Unix
(
int64
(
jd
),
0
)
}
func
JulianDay
(
t
*
time
.
Time
)
float64
{
ns
:=
float64
(
t
.
Nanoseconds
())
func
JulianDay
(
t
time
.
Time
)
float64
{
ns
:=
float64
(
t
.
Unix
())
if
ns
>=
0
{
ns
+=
0.5
}
return
ns
/
DAY_IN_
NANO
SECONDS
+
JULIAN_DAY
return
ns
/
DAY_IN_SECONDS
+
JULIAN_DAY
}
date_test.go
View file @
ddcc9654
...
...
@@ -7,12 +7,12 @@ import (
func
TestJulianDay
(
t
*
testing
.
T
)
{
utc
:=
JulianDayToUTC
(
JULIAN_DAY
)
if
utc
.
Nanoseconds
()
!=
0
{
t
.
Errorf
(
"Error, expecting %d got %d"
,
0
,
utc
.
Nanoseconds
())
if
utc
.
Unix
()
!=
0
{
t
.
Errorf
(
"Error, expecting %d got %d"
,
0
,
utc
.
Unix
())
}
now
:=
time
.
LocalTime
()
now
:=
time
.
Now
()
r
:=
JulianDayToLocalTime
(
JulianDay
(
now
))
if
r
.
Nanoseconds
()
/
10000
!=
now
.
Nanoseconds
()
/
10000
{
// FIXME Rounding problem?
if
r
.
Unix
()
!=
now
.
Unix
()
{
// FIXME Rounding problem?
t
.
Errorf
(
"%#v <> %#v"
,
now
,
r
)
}
}
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