-
-
Save marcs-feh/bcc6101e2e0340a5014afc967066c601 to your computer and use it in GitHub Desktop.
yes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
const BlocksPerDay = 48 | |
type Block struct { | |
Description string | |
Start int | |
Duration int | |
} | |
type Week struct { | |
Days [7][]Block | |
BaseDate time.Time | |
} | |
func newWeek() Week { | |
week := Week{} | |
for i := range 7 { | |
week.Days[i] = make([]Block, 0) | |
} | |
return week | |
} | |
const layoutHourMinute = "15:04" | |
func printWeek(week Week) { | |
step := time.Minute * 30 | |
for dayNum, _ := range week.Days { | |
fmt.Println("---", time.Weekday(dayNum), "---") | |
for i := range BlocksPerDay { | |
date := week.BaseDate.AddDate(0, 0, dayNum) | |
date = date.Add(time.Duration(i) * step) | |
fmt.Println(date.Format(layoutHourMinute)) | |
} | |
} | |
} | |
func main(){ | |
week := newWeek() | |
week.BaseDate, _ = time.Parse(time.DateOnly, time.Now().Format(time.DateOnly)) | |
printWeek(week) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment