func (fs *FileSystem) now() time.Time {
	return fs.truncate(fs.myNow().UTC(), fs.duration)
}
now returns current time stamp rounded down to 1 hour.  All timestamps are
UTC.
package filesystem
import (
	"bytes"
	"crypto/sha256"
	"encoding/binary"
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	"sort"
	"sync"
	"time"
	"github.com/decred/dcrtime/dcrtimed/backend"
	"github.com/decred/dcrtime/dcrtimed/dcrtimewallet"
	"github.com/decred/dcrtime/merkle"
	"github.com/robfig/cron"
	"github.com/syndtr/goleveldb/leveldb"
	"github.com/syndtr/goleveldb/leveldb/opt"
)
const (
	fStr          = "20060102.150405"
	globalDBDir   = "global"
	flushedKey    = "flushed"
	confirmations = 6
	foundGlobal = 1000
	foundLocal = 1001
	foundPrevious = 1002
)
var (
	_ backend.Backend = (*FileSystem)(nil)
	flushSchedule = "10 0 * * * *"  
	duration      = time.Hour       
	errInvalidDB      = errors.New("not a database")  
	errAlreadyFlushed = errors.New("already flushed")
	errEmptySet       = errors.New("empty set")
)
type FileSystem struct {
	sync.RWMutex
	cron     *cron.Cron     
	root     string         
	db       *leveldb.DB    
	duration time.Duration  
	commit   uint           
	enableCollections bool  
	wallet *dcrtimewallet.DcrtimeWallet  
	myNow   func() time.Time  
	testing bool              
}
func ts2dirname(ts int64) string {
	return time.Unix(ts, 0).UTC().Format(fStr)
}
func EncodeFlushRecord(fr backend.FlushRecord) ([]byte, error) {
	b, err := json.Marshal(fr)
	if err != nil {
		return nil, err
	}
	return b, nil
}
func DecodeFlushRecord(payload []byte) (*backend.FlushRecord, error) {
	var fr backend.FlushRecord
	err := json.Unmarshal(payload, &fr)
	if err != nil {
		return nil, err
	}
	return &fr, nil
}