-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from lowply/lowply/more-variables
Allow formatting in the template
- Loading branch information
Showing
6 changed files
with
73 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/jinzhu/now" | ||
) | ||
|
||
type data struct { | ||
Current time.Time | ||
WeekStart time.Time | ||
WeekEnd time.Time | ||
WeekNumber string | ||
YearOfTheWeek string | ||
Dates [7]time.Time | ||
} | ||
|
||
func NewData(t time.Time) *data { | ||
d := &data{} | ||
|
||
nc := &now.Config{ | ||
WeekStartDay: time.Monday, | ||
} | ||
n := nc.With(t) | ||
|
||
// https://github.com/jinzhu/now#mondaysunday | ||
d.Current = t | ||
d.WeekStart = n.Monday() | ||
d.WeekEnd = n.Sunday() | ||
|
||
_, isoweek := n.Monday().ISOWeek() | ||
d.WeekNumber = fmt.Sprintf("%02d", isoweek) | ||
|
||
// Thursday of the week, should be used with the week number | ||
// e.g. "2020 Week 01". | ||
// See https://en.wikipedia.org/wiki/ISO_week_date#First_week | ||
// for the ISO 8601 first week definition | ||
d.YearOfTheWeek = n.BeginningOfWeek().AddDate(0, 0, 3).Format("2006") | ||
|
||
for j := range d.Dates { | ||
d.Dates[j] = n.Monday().AddDate(0, 0, j) | ||
} | ||
return d | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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