I tried to run a time script. But according to the code, it should return a 
very long list of date range. But it failed to do so. Can you please give me an 
explanation or some documentation which specifies that golang doesn't support 
time values (like it doesn't support for file handling operations.)

PFA file




Thanks and Regards,
Sahil Agrawal

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/AM5PR03MB3057DBC2104DF2379A7DF3E6FA0C0%40AM5PR03MB3057.eurprd03.prod.outlook.com.
package main

import (
	"fmt"
	"time"
)

func main() {
	fmt.Println("Hello, playground")
	var dateRanges [][2]string 
	var startFrom time.Time
	now := time.Now().Local()
	startFrom = time.Date(2009, time.January, 1, 0, 0, 0, 0, time.Local)
	date := startFrom
	fmt.Println("Ztime",now)
	for now.After(date) {
		// add a 7 day range to the list
		dateRanges = append(dateRanges, [2]string{
			date.Format("2006-01-02"),
			date.Add(24 * time.Hour * 7).Format("2006-01-02"),
		})

		// increment date by 8 days
		date = date.Add(24 * time.Hour * 8)
		//fmt.Println(date)
		
	}
	
	for _, i:= range dateRanges {
		fmt.Println(i)
	}
}

Reply via email to