Skip to content

Commit

Permalink
Changed date fields to actually be stored as datetime objects, rather…
Browse files Browse the repository at this point in the history
… than as strings.
  • Loading branch information
jaredbischof committed Apr 4, 2014
1 parent c5cfbb7 commit f3e8fcf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions shock-server/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/MG-RAST/golib/mgo/bson"
"io/ioutil"
"os"
"time"
)

type Node struct {
Expand All @@ -27,8 +28,8 @@ type Node struct {
Tags []string `bson:"tags" json:"tags"`
Revisions []Node `bson:"revisions" json:"-"`
Linkages []linkage `bson:"linkage" json:"linkages"`
CreatedOn string `bson:"created_on" json:"created_on"`
LastModified string `bson:"last_modified" json:"last_modified"`
CreatedOn time.Time `bson:"created_on" json:"created_on"`
LastModified time.Time `bson:"last_modified" json:"last_modified"`
}

type linkage struct {
Expand Down Expand Up @@ -58,7 +59,6 @@ func New() (node *Node) {
node.Indexes = make(map[string]IdxInfo)
node.File.Checksum = make(map[string]string)
node.setId()
node.LastModified = "-"
return
}

Expand Down
6 changes: 3 additions & 3 deletions shock-server/node/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ func (node *Node) Save() (err error) {
n := Node{node.Id, node.Version, node.File, node.Attributes, node.Public, node.Indexes, node.Acl, node.VersionParts, node.Tags, nil, node.Linkages, node.CreatedOn, node.LastModified}
node.Revisions = append(node.Revisions, n)
}
if node.CreatedOn == "" {
node.CreatedOn = time.Now().Format(time.UnixDate)
if node.CreatedOn.String() == "" {
node.CreatedOn = time.Now()
} else {
node.LastModified = time.Now().Format(time.UnixDate)
node.LastModified = time.Now()
}

bsonPath := fmt.Sprintf("%s/%s.bson", node.Path(), node.Id)
Expand Down

0 comments on commit f3e8fcf

Please sign in to comment.