26 lines
513 B
Go
26 lines
513 B
Go
|
|
package placement
|
||
|
|
|
||
|
|
import "time"
|
||
|
|
|
||
|
|
const (
|
||
|
|
MaxPostAgeDays = 30
|
||
|
|
IdealMaxPostAgeDays = 7
|
||
|
|
WebSearchMaxAgeDays = 14
|
||
|
|
)
|
||
|
|
|
||
|
|
func FormatAfterDate(maxAgeDays int, now time.Time) string {
|
||
|
|
if now.IsZero() {
|
||
|
|
now = time.Now()
|
||
|
|
}
|
||
|
|
date := now.AddDate(0, 0, -maxAgeDays).UTC()
|
||
|
|
return date.Format("2006-01-02")
|
||
|
|
}
|
||
|
|
|
||
|
|
func FormatPublishedAfterISO(maxAgeDays int, now time.Time) string {
|
||
|
|
if now.IsZero() {
|
||
|
|
now = time.Now()
|
||
|
|
}
|
||
|
|
date := now.AddDate(0, 0, -maxAgeDays).UTC()
|
||
|
|
return date.Format("2006-01-02T15:04:05.000Z")
|
||
|
|
}
|