From ba8d3148ee99d18db4d6e3e69981b7e29b6e392f Mon Sep 17 00:00:00 2001 From: Andinus Date: Sun, 15 Mar 2020 17:29:01 +0530 Subject: cetus-bing: Correct date format --- cmd/cetus-bing/cetus-bing.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/cetus-bing/cetus-bing.go b/cmd/cetus-bing/cetus-bing.go index e4aae89..9b06379 100644 --- a/cmd/cetus-bing/cetus-bing.go +++ b/cmd/cetus-bing/cetus-bing.go @@ -63,7 +63,18 @@ func main() { // responses, choose a random response from the list var i int = rand.Intn(len(bpodRes.Photos)) bpodPhoto = bpodRes.Photos[i] + + // correct image path bpodPhoto.URL = fmt.Sprintf("%s%s", "https://www.bing.com", bpodPhoto.URL) + + // correct date format + var dt time.Time + dt, err = time.Parse("20060102", bpodPhoto.StartDate) + if err != nil { + log.Fatal(err) + } + bpodPhoto.StartDate = dt.Format("2006-01-02") + printDetails(bpodPhoto) // if fetchOnly is true then don't set background @@ -105,7 +116,7 @@ func printDetails(bpodPhoto bing.Photo) { fmt.Printf("Copyright: %s\n", bpodPhoto.Copyright) fmt.Printf("Copyright Link: %s\n", bpodPhoto.CopyrightLink) fmt.Printf("Date: %s\n\n", bpodPhoto.StartDate) - fmt.Printf("URL: %s\n\n", bpodPhoto.URL) + fmt.Printf("URL: %s\n", bpodPhoto.URL) } func getBPODRes() (bing.BPOD, error) { -- cgit 1.4.1-2-gfad0