123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- package tag
- import (
- "fmt"
- "jy/src/jfw/config"
- "strconv"
- "strings"
- "time"
- util "app.yhyue.com/moapp/jybase/common"
- )
- // 从json配置文件中读取值
- func Export() map[string]interface{} {
- return config.ExportConfig
- }
- // 从json配置文件中读取值
- func Msg(mtype, key string) string {
- return readproperty(mtype, key)
- }
- func DateTip(date2 int64) (timedate string) {
- timedate = "30秒前"
- date1 := time.Now().Unix()
- td := date1 - date2
- //天数
- var days = td / (24 * 3600)
- //小时
- var leave1 = td % (24 * 3600)
- var hours = leave1 / 3600
- //分钟
- var leave2 = leave1 % 3600
- var minutes = leave2 / 60
- if days > 0 {
- if days > 10 {
- var date1fm = time.Unix(date1, 0).Format("2006-01-02")
- var date2fm = time.Unix(date2, 0).Format("2006-01-02")
- date1fmyear := strings.Split(date1fm, "-")[0]
- date2fmyear := strings.Split(date2fm, "-")[0]
- if date1fmyear > date2fmyear {
- timedate = date2fm
- } else {
- timedate = time.Unix(date2, 0).Format("01-02")
- }
- } else {
- timedate = strconv.FormatInt(days, 10) + "天"
- }
- } else if hours > 0 {
- timedate = strconv.FormatInt(hours, 10) + "小时"
- } else if minutes > 0 {
- timedate = strconv.FormatInt(minutes, 10) + "分钟"
- }
- return
- }
- func readproperty(mtype, key string) string {
- switch mtype {
- case "seo":
- if key == "version" && config.Seoconfig_Version != "" {
- return config.Seoconfig_Version
- }
- if strings.HasSuffix(key, "_v") {
- avk := applyVersion[key]
- if avk != "" {
- return avk
- }
- return config.Seoconfig_Version
- }
- tmp := util.GetPropertie(key, config.Seoconfig)
- if tmp == nil {
- return ""
- } else {
- ret, _ := tmp.(string)
- return ret
- }
- case "date":
- fmt.Println(key, "--------")
- timedate := "30秒前"
- if len(key) > 0 {
- var date1 int64
- var date2 int64
- date1 = time.Now().Unix()
- date2, _ = strconv.ParseInt(key, 10, 0)
- td := date1 - date2
- //天数
- var days = td / (24 * 3600)
- //小时
- var leave1 = td % (24 * 3600)
- var hours = leave1 / 3600
- //分钟
- var leave2 = leave1 % 3600
- var minutes = leave2 / 60
- if days > 0 {
- if days > 10 {
- var date1fm = time.Unix(date1, 0).Format("2006-01-02")
- var date2fm = time.Unix(date2, 0).Format("2006-01-02")
- date1fmyear := strings.Split(date1fm, "-")[0]
- date2fmyear := strings.Split(date2fm, "-")[0]
- if date1fmyear > date2fmyear {
- timedate = date2fm
- } else {
- timedate = time.Unix(date2, 0).Format("01-02")
- }
- } else {
- timedate = strconv.FormatInt(days, 10) + "天"
- }
- } else if hours > 0 {
- timedate = strconv.FormatInt(hours, 10) + "小时"
- } else if minutes > 0 {
- timedate = strconv.FormatInt(minutes, 10) + "分钟"
- }
- }
- return timedate
- default:
- return ""
- }
- }
|