diff options
author | Adam Mathes <adam@trenchant.org> | 2017-02-09 20:14:46 -0800 |
---|---|---|
committer | Adam Mathes <adam@trenchant.org> | 2017-02-09 20:14:46 -0800 |
commit | 50f608846f1021db4f2335744cc023231fb74652 (patch) | |
tree | d75e57955029ebcda9da72a29e3c7555e02b4eb5 /post | |
parent | ded6e3b25bca083cabe21bda6f4d01f6766587bc (diff) | |
download | snkt-50f608846f1021db4f2335744cc023231fb74652.tar.gz snkt-50f608846f1021db4f2335744cc023231fb74652.tar.bz2 snkt-50f608846f1021db4f2335744cc023231fb74652.zip |
fix some templates, add verbose-logger
Diffstat (limited to 'post')
-rw-r--r-- | post/post.go | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/post/post.go b/post/post.go index 19a8e73..ab1ccb6 100644 --- a/post/post.go +++ b/post/post.go @@ -8,6 +8,7 @@ import ( "snkt/config" "snkt/render" "snkt/text" + "snkt/vlog" "github.com/russross/blackfriday" "io/ioutil" "log" @@ -130,18 +131,20 @@ func (p *Post) parse() { if len(ds) > 0 { date_str = ds[0] } - var err error - p.Time, err = time.Parse("2006-1-2", date_str) - if err != nil { - - if config.Config.Verbose { - log.Println(err) - } - // fallback is to use file modtime - // should use create time but that doesn't seem to be in stdlib - // TODO: figure out how to use file birth time + if date_str == "" { p.Time = p.FileInfo.ModTime() + vlog.Printf("no date field in post %s, using file modification time\n", p.SourceFile) + } else { + var err error + p.Time, err = time.Parse("2006-1-2", date_str) + if err != nil { + // fallback is to use file modtime + // should use create time but that doesn't seem to be in stdlib + // TODO: figure out how to use file birth time + vlog.Printf("no valid date parsed for post %s, using file modification time\n", p.SourceFile) + p.Time = p.FileInfo.ModTime() + } } p.Year, p.Month, p.Day = p.Time.Date() |