format_utility.go 485 Bytes
package webutility

import (
	"time"
	"fmt"
)

func UnixToDate(unix int64) time.Time {
	return time.Unix(unix, 0)
}

func DateToUnix(date interface{}) int64 {
	if date != nil {
		t := date.(time.Time)
		return t.Unix()

	}
	return 0
}

func EqualQuotes(stmt string) string {
	if stmt != "" {
		stmt = fmt.Sprintf(" = '%s'", stmt)
	}
	return stmt
}

func LikeQuotes(stmt string) string {
	if stmt != "" {
		stmt = fmt.Sprintf(" LIKE UPPER('%s%s%s')", "%", stmt, "%")
	}
	return stmt
}