From 1eb287e67decc2350932e8047282fbb18d79ca85 Mon Sep 17 00:00:00 2001 From: kondoumh Date: Fri, 5 Jun 2020 07:17:27 +0900 Subject: [PATCH] Add date prop --- cmd/fetch.go | 4 ++++ pkg/types/project.go | 1 + 2 files changed, 5 insertions(+) diff --git a/cmd/fetch.go b/cmd/fetch.go index ed99cdc..8019acc 100644 --- a/cmd/fetch.go +++ b/cmd/fetch.go @@ -13,6 +13,8 @@ import ( "github.com/spf13/cobra" ) +const timeLayout = "2006-01-02 15:04" + var fetchCmd = &cobra.Command{ Use: "fetch", Short: "Fetch all pages of the project", @@ -87,6 +89,8 @@ func fetchPageList(project types.Project) error { } } project.Pages = pages + jst, _ := time.LoadLocation("Asia/Tokyo") + project.Date = time.Now().In(jst).Format(timeLayout) data, _ := json.Marshal(project) if err := file.WriteBytes(data, project.Name+".json", config.WorkDir); err != nil { return err diff --git a/pkg/types/project.go b/pkg/types/project.go index 1eb1290..30badb0 100644 --- a/pkg/types/project.go +++ b/pkg/types/project.go @@ -9,6 +9,7 @@ import ( // Project represents a Scrapbox project type Project struct { Name string `json:"projectName"` + Date string `json:"date"` Count int `json:"count"` Skip int `json:"skip"` Pages []Page `json:"pages"`