summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@inventati.org>2020-03-15 17:29:01 +0530
committerAndinus <andinus@inventati.org>2020-03-15 17:29:01 +0530
commitba8d3148ee99d18db4d6e3e69981b7e29b6e392f (patch)
tree9d0534237a4fcadb7a2df6f0926cc45e19559ea1
parenta22d31258ff92d8b2e199e1bdd6e898c6519c707 (diff)
downloadcetus-ba8d3148ee99d18db4d6e3e69981b7e29b6e392f.tar.gz
cetus-bing: Correct date format v0.4.5
-rw-r--r--cmd/cetus-bing/cetus-bing.go13
1 files changed, 12 insertions, 1 deletions
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) {