diff --git a/layouts/shortcodes/calendar.html b/layouts/shortcodes/calendar.html index e11f3bc..76d611e 100644 --- a/layouts/shortcodes/calendar.html +++ b/layouts/shortcodes/calendar.html @@ -1,29 +1,31 @@ -{{ $month := .Get "month" }} -{{ if not $month }} - {{ errorf "Error: 'month' is a required parameter." }} +{{ $date:= .Get "date" }} +{{ if not $date }} + {{ errorf "Error: 'date' is a required parameter." }} {{ end }} +{{ $date := time.AsTime $date }} -{{ $year := .Get "year" }} -{{ if not $year }} - {{ errorf "Error: 'year' is a required parameter." }} -{{ end }} +{{ $month := $date.Month | int }} +{{ $year := $date.Year }} -{{ $label := .Get "label" }} -{{ if not $label }} - {{ errorf "Error: 'label' is a required parameter." }} -{{ end }} +{{ $t1 := printf "%4d-%02d-01" $year $month }} +{{ $t1 := time.AsTime $t1 }} +{{ $t2 := $t1.AddDate 0 1 0 }} +{{ $daysInMonth := $t2.Sub $t1 }} +{{ $daysInMonth := $daysInMonth.Hours }} +{{ $daysInMonth := div $daysInMonth 24 }} -{{ $daysInMonth := 27 }} - +{{ $padding := $t1.Weekday | int }}