- more interface and const added.

This commit is contained in:
gazebo
2018-07-10 13:28:22 +08:00
parent 7c54e7da92
commit 5702df37b0
8 changed files with 217 additions and 14 deletions

View File

@@ -163,10 +163,23 @@ func Timestamp2Str(timestamp int64) string {
return Time2Str(time.Unix(timestamp, 0))
}
func Timestamp2Time(timestamp int64) time.Time {
return time.Unix(timestamp, 0)
}
func Time2Str(t time.Time) string {
return t.Format("2006-01-02 15:04:05")
}
func Str2Time(timeStr string) time.Time {
timeStr = strings.Replace(timeStr, "T", " ", 1)
retVal, err := time.ParseInLocation("2006-01-02 15:04:05", timeStr, time.Local)
if err != nil {
baseapi.SugarLogger.Errorf("ParseInLocation failed, timeStr:%v, error:%v", timeStr, err)
}
return retVal
}
func HTTPResponse2Json(response *http.Response) (map[string]interface{}, error) {
var jsonResult map[string]interface{}
bodyData, err := ioutil.ReadAll(response.Body)