URI: 
       Always use RFC3339 for version date format. - hugo - [fork] hugo port for 9front
  HTML git clone git@git.drkhsh.at/hugo.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit 27840932a5da2a9ccb6ed486c1c27afb3347f2b1
   DIR parent a0d956c2ad7371d989fc192e122f0097b07a5b01
  HTML Author: Austin Ziegler <austin@zieglers.ca>
       Date:   Fri,  5 Dec 2014 23:11:43 -0500
       
       Always use RFC3339 for version date format.
       
       Fixes #695 reported by @synful.
       
       - No longer tries to load a configuration.
       - Because of this the version tests are no longer necessary.
       
       Diffstat:
         M commands/version.go                 |      33 ++-----------------------------
         D commands/version_test.go            |      71 -------------------------------
       
       2 files changed, 2 insertions(+), 102 deletions(-)
       ---
   DIR diff --git a/commands/version.go b/commands/version.go
       @@ -22,7 +22,6 @@ import (
        
                "bitbucket.org/kardianos/osext"
                "github.com/spf13/cobra"
       -        "github.com/spf13/viper"
        )
        
        var timeLayout string // the layout for time.Time
       @@ -37,7 +36,6 @@ var version = &cobra.Command{
                Short: "Print the version number of Hugo",
                Long:  `All software has versions. This is Hugo's`,
                Run: func(cmd *cobra.Command, args []string) {
       -                InitializeConfig()
                        if buildDate == "" {
                                setBuildDate() // set the build date from executable's mdate
                        } else {
       @@ -70,39 +68,12 @@ func setBuildDate() {
                        return
                }
                t := fi.ModTime()
       -        buildDate = t.Format(getDateFormat())
       +        buildDate = t.Format(time.RFC3339)
        }
        
        // formatBuildDate formats the buildDate according to the value in
        // .Params.DateFormat, if it's set.
        func formatBuildDate() {
                t, _ := time.Parse("2006-01-02T15:04:05", buildDate)
       -        buildDate = t.Format(getDateFormat())
       -}
       -
       -// getDateFormat gets the dateFormat value from Params. The dateFormat should
       -// be a valid time layout. If it isn't set, time.RFC3339 is used.
       -func getDateFormat() string {
       -        params := viper.Get("params")
       -        if params == nil {
       -                return time.RFC3339
       -        }
       -
       -        //        var typMapIfaceIface = reflect.TypeOf(map[interface{}{}]interface{}{})
       -        //        var typMapStringIface = reflect.TypeOf(map[string]interface{}{})
       -        parms := map[string]interface{}{}
       -        switch params.(type) {
       -        case map[interface{}]interface{}:
       -                for k, v := range params.(map[interface{}]interface{}) {
       -                        parms[k.(string)] = v
       -                }
       -        case map[string]interface{}:
       -                parms = params.(map[string]interface{})
       -        }
       -
       -        layout := parms["DateFormat"]
       -        if layout == nil || layout == "" {
       -                return time.RFC3339
       -        }
       -        return layout.(string)
       +        buildDate = t.Format(time.RFC3339)
        }
   DIR diff --git a/commands/version_test.go b/commands/version_test.go
       @@ -1,71 +0,0 @@
       -package commands
       -
       -import (
       -        "io/ioutil"
       -        "testing"
       -
       -        "github.com/spf13/viper"
       -        "github.com/stretchr/testify/assert"
       -)
       -
       -// config json
       -var JSONConfig = []byte(`{
       -        "params": {
       -                "DateFormat": "Jan 2 2006"
       -        }                
       -}`)
       -
       -// config toml
       -var TOMLConfig = []byte(`
       -[params]
       -DateFormat =  "Jan 2 2006"
       -`)
       -
       -// config yaml
       -var YAMLConfig = []byte(`
       -params:
       -  DateFormat: "Jan 2 2006"
       -`)
       -
       -var config map[string]interface{} = make(map[string]interface{})
       -
       -func TestGetDateFormatJSON(t *testing.T) {
       -        jsonFile, _ := ioutil.TempFile("", "config.json")
       -        fname := jsonFile.Name()
       -        jsonFile.Write(JSONConfig)
       -        jsonFile.Close()
       -        viper.SetConfigFile(fname)
       -        viper.SetConfigType("json")
       -        viper.ReadInConfig()
       -
       -        dateFmt := getDateFormat()
       -        assert.Equal(t, "Jan 2 2006", dateFmt)
       -}
       -
       -func TestGetDateFormatTOML(t *testing.T) {
       -        viper.Reset()
       -        tomlFile, _ := ioutil.TempFile("", "config.toml")
       -        fname := tomlFile.Name()
       -        tomlFile.Write(TOMLConfig)
       -        tomlFile.Close()
       -        viper.SetConfigFile(fname)
       -        viper.SetConfigType("toml")
       -        viper.ReadInConfig()
       -
       -        dateFmt := getDateFormat()
       -        assert.Equal(t, "Jan 2 2006", dateFmt)
       -}
       -
       -func TestGetDateFormatYAML(t *testing.T) {
       -        viper.Reset()
       -        yamlFile, _ := ioutil.TempFile("", "config.yaml")
       -        fname := yamlFile.Name()
       -        yamlFile.Write(YAMLConfig)
       -        yamlFile.Close()
       -        viper.SetConfigFile(fname)
       -        viper.SetConfigType("yaml")
       -        viper.ReadInConfig()
       -
       -        dateFmt := getDateFormat()
       -        assert.Equal(t, "Jan 2 2006", dateFmt)
       -}