From 957195ca1183661b9c76d064464e4da2b7cd3d65 Mon Sep 17 00:00:00 2001 From: mappu Date: Wed, 6 Sep 2017 18:17:25 +1200 Subject: [PATCH] convert time specs to strftime --- ArchiveServer.go | 4 +++- cmd/archive-server/config.json.SAMPLE | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ArchiveServer.go b/ArchiveServer.go index a062448..93216eb 100644 --- a/ArchiveServer.go +++ b/ArchiveServer.go @@ -5,6 +5,8 @@ import ( "fmt" "regexp" "time" + + "github.com/jehiah/go-strftime" ) var ( @@ -57,7 +59,7 @@ func (this *ArchiveServer) LogFile(ls *LogSource, ym YearMonth) (string, error) for _, fl := range ls.FileLocation { 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 } } diff --git a/cmd/archive-server/config.json.SAMPLE b/cmd/archive-server/config.json.SAMPLE index 33b18f2..89b832f 100644 --- a/cmd/archive-server/config.json.SAMPLE +++ b/cmd/archive-server/config.json.SAMPLE @@ -25,9 +25,9 @@ /* * 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.