Commit ddcc9654 authored by gwenn's avatar gwenn

Upgrade to weekly release.

parent b5ce2308
...@@ -74,7 +74,7 @@ func (b *Backup) Status() BackupStatus { ...@@ -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 // 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 var err error
for { for {
err = b.Step(npage) err = b.Step(npage)
......
...@@ -11,25 +11,25 @@ import ( ...@@ -11,25 +11,25 @@ import (
) )
const ( const (
JULIAN_DAY = 2440587.5 // 1970-01-01 00:00:00 is JD 2440587.5 JULIAN_DAY = 2440587.5 // 1970-01-01 00:00:00 is JD 2440587.5
DAY_IN_NANOSECONDS = 60 * 60 * 24 * 10E6 DAY_IN_SECONDS = 60 * 60 * 24
) )
func JulianDayToUTC(jd float64) *time.Time { func JulianDayToUTC(jd float64) time.Time {
jd -= JULIAN_DAY jd -= JULIAN_DAY
jd *= DAY_IN_NANOSECONDS jd *= DAY_IN_SECONDS
return time.NanosecondsToUTC(int64(jd)) return time.Unix(int64(jd), 0).UTC()
} }
func JulianDayToLocalTime(jd float64) *time.Time { func JulianDayToLocalTime(jd float64) time.Time {
jd -= JULIAN_DAY jd -= JULIAN_DAY
jd *= DAY_IN_NANOSECONDS jd *= DAY_IN_SECONDS
return time.NanosecondsToLocalTime(int64(jd)) return time.Unix(int64(jd), 0)
} }
func JulianDay(t *time.Time) float64 { func JulianDay(t time.Time) float64 {
ns := float64(t.Nanoseconds()) ns := float64(t.Unix())
if ns >= 0 { if ns >= 0 {
ns += 0.5 ns += 0.5
} }
return ns/DAY_IN_NANOSECONDS + JULIAN_DAY return ns/DAY_IN_SECONDS + JULIAN_DAY
} }
...@@ -7,12 +7,12 @@ import ( ...@@ -7,12 +7,12 @@ import (
func TestJulianDay(t *testing.T) { func TestJulianDay(t *testing.T) {
utc := JulianDayToUTC(JULIAN_DAY) utc := JulianDayToUTC(JULIAN_DAY)
if utc.Nanoseconds() != 0 { if utc.Unix() != 0 {
t.Errorf("Error, expecting %d got %d", 0, utc.Nanoseconds()) t.Errorf("Error, expecting %d got %d", 0, utc.Unix())
} }
now := time.LocalTime() now := time.Now()
r := JulianDayToLocalTime(JulianDay(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) t.Errorf("%#v <> %#v", now, r)
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment