Skip to content

Instantly share code, notes, and snippets.

@marcs-feh
Created October 28, 2024 00:58
Show Gist options
  • Save marcs-feh/bcc6101e2e0340a5014afc967066c601 to your computer and use it in GitHub Desktop.
Save marcs-feh/bcc6101e2e0340a5014afc967066c601 to your computer and use it in GitHub Desktop.
yes
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