convert time specs to strftime
This commit is contained in:
parent
bed15bfb33
commit
957195ca11
@ -5,6 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/jehiah/go-strftime"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -57,7 +59,7 @@ func (this *ArchiveServer) LogFile(ls *LogSource, ym YearMonth) (string, error)
|
|||||||
|
|
||||||
for _, fl := range ls.FileLocation {
|
for _, fl := range ls.FileLocation {
|
||||||
if fl.StartMonth.Index() <= ymIndex && (fl.EndMonth == nil || fl.EndMonth.Index() >= ymIndex) {
|
if fl.StartMonth.Index() <= ymIndex && (fl.EndMonth == nil || fl.EndMonth.Index() >= ymIndex) {
|
||||||
return time.Date(ym.Year, ym.Month, 1, 0, 0, 0, 0, this.timezone).Format(fl.LogFilePath), nil
|
return strftime.Format(fl.LogFilePath, time.Date(ym.Year, ym.Month, 1, 0, 0, 0, 0, this.timezone)), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* The full path to the log file.
|
* The full path to the log file.
|
||||||
* Date formatting reference: https://golang.org/pkg/time/#pkg-constants
|
* Date formatting reference: http://strftime.org/
|
||||||
*/
|
*/
|
||||||
"LogFilePath": "/path/to/my-log-source/2006-01.log",
|
"LogFilePath": "/path/to/my-log-source/%Y-%m.log",
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The first month for which this path is valid.
|
* The first month for which this path is valid.
|
||||||
|
Loading…
Reference in New Issue
Block a user