Skip to content

Instantly share code, notes, and snippets.

@innermond
Created November 22, 2018 22:39
Show Gist options
  • Save innermond/32f3b3fd275d9385ec9b2d963a9659a0 to your computer and use it in GitHub Desktop.
Save innermond/32f3b3fd275d9385ec9b2d963a9659a0 to your computer and use it in GitHub Desktop.
print a basic text version of a year's month
package main
import (
"fmt"
"time"
)
func main() {
year, m := 2018, time.Month(1)
tfirst := time.Date(year, m, 1, 0, 0, 0, 0, time.UTC)
da, wa := tfirst.Day(), tfirst.Weekday()
tlast := time.Date(year, m+1, 0, 0, 0, 0, 0, time.UTC)
dz, wz := tlast.Day(), tlast.Weekday()
x := 0
for ; x < int(wa); x++ {
fmt.Print(" ")
}
d := 1
for ; d <= dz; d++ {
if (d+int(wa)-1)%7 == 0 {
fmt.Println(d, " ")
} else {
fmt.Print(d, " ")
}
}
fmt.Println("\n", da, wa, int(wa), dz, wz, int(wz))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment