Skip to content

Commit

Permalink
🎨 Add created and updated type column to database #9371
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Oct 9, 2023
1 parent 9288e52 commit 644e031
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions kernel/model/attribute_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ func renderTemplateCol(ial map[string]string, tplContent string, rowValues []*av
if "" != createdStr {
createdStr = createdStr[:len("20060102150405")]
}
created, parseErr := time.Parse("20060102150405", createdStr)
created, parseErr := time.ParseInLocation("20060102150405", createdStr, time.Local)
if nil == parseErr {
dataModel["created"] = created
} else {
logging.LogWarnf("parse created [%s] failed: %s", createdStr, parseErr)
dataModel["created"] = time.Now()
}
updatedStr := ial["updated"]
updated, parseErr := time.Parse("20060102150405", updatedStr)
updated, parseErr := time.ParseInLocation("20060102150405", updatedStr, time.Local)
if nil == parseErr {
dataModel["updated"] = updated
} else {
Expand Down Expand Up @@ -151,7 +151,7 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
}
case av.KeyTypeCreated:
createdStr := blockID[:len("20060102150405")]
created, parseErr := time.Parse("20060102150405", createdStr)
created, parseErr := time.ParseInLocation("20060102150405", createdStr, time.Local)
if nil == parseErr {
kv.Values[0].Created = av.NewFormattedValueCreated(created.UnixMilli(), 0, av.CreatedFormatNone)
} else {
Expand All @@ -161,7 +161,7 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
case av.KeyTypeUpdated:
ial := GetBlockAttrs(blockID)
updatedStr := ial["updated"]
updated, parseErr := time.Parse("20060102150405", updatedStr)
updated, parseErr := time.ParseInLocation("20060102150405", updatedStr, time.Local)
if nil == parseErr {
kv.Values[0].Updated = av.NewFormattedValueUpdated(updated.UnixMilli(), 0, av.UpdatedFormatNone)
} else {
Expand Down Expand Up @@ -364,7 +364,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
cell.Value.Template.Content = content
case av.KeyTypeCreated: // 渲染创建时间
createdStr := row.ID[:len("20060102150405")]
created, parseErr := time.Parse("20060102150405", createdStr)
created, parseErr := time.ParseInLocation("20060102150405", createdStr, time.Local)
if nil == parseErr {
cell.Value.Created = av.NewFormattedValueCreated(created.UnixMilli(), 0, av.CreatedFormatNone)
} else {
Expand All @@ -374,7 +374,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
case av.KeyTypeUpdated: // 渲染更新时间
ial := GetBlockAttrs(row.ID)
updatedStr := ial["updated"]
updated, parseErr := time.Parse("20060102150405", updatedStr)
updated, parseErr := time.ParseInLocation("20060102150405", updatedStr, time.Local)
if nil == parseErr {
cell.Value.Updated = av.NewFormattedValueUpdated(updated.UnixMilli(), 0, av.UpdatedFormatNone)
} else {
Expand Down

0 comments on commit 644e031

Please sign in to comment.