github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/timeutil/language.go (about) 1 // Copyright 2023 The GitBundle Inc. All rights reserved. 2 // Copyright 2017 The Gitea Authors. All rights reserved. 3 // Use of this source code is governed by a MIT-style 4 // license that can be found in the LICENSE file. 5 6 package timeutil 7 8 import ( 9 "time" 10 11 "github.com/gitbundle/modules/setting" 12 ) 13 14 var langTimeFormats = map[string]string{ 15 "zh-CN": "2006年01月02日 15时04分05秒", 16 "en-US": time.RFC1123, 17 "lv-LV": "02.01.2006. 15:04:05", 18 } 19 20 // GetLangTimeFormat represents the default time format for the language 21 func GetLangTimeFormat(lang string) string { 22 return langTimeFormats[lang] 23 } 24 25 // GetTimeFormat represents the 26 func GetTimeFormat(lang string) string { 27 if setting.TimeFormat == "" { 28 format := GetLangTimeFormat(lang) 29 if format == "" { 30 format = time.RFC1123 31 } 32 return format 33 } 34 return setting.TimeFormat 35 }