From e52cda3e2a7c30cd51978983bcda606c2849e21b Mon Sep 17 00:00:00 2001
From: Yarden Shoham <git@yardenshoham.com>
Date: Sat, 29 Apr 2023 17:20:01 +0000
Subject: [PATCH 1/3] Remove unused setting `time.FORMAT`

It's loaded and then never used.
---
 custom/conf/app.example.ini                   |  5 ---
 .../config-cheat-sheet.en-us.md               |  1 -
 modules/setting/time.go                       | 33 -------------------
 modules/timeutil/language.go                  | 33 -------------------
 4 files changed, 72 deletions(-)
 delete mode 100644 modules/timeutil/language.go

diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini
index 3687e0fbd4caf..f22d555704bc0 100644
--- a/custom/conf/app.example.ini
+++ b/custom/conf/app.example.ini
@@ -1899,11 +1899,6 @@ ROUTER = console
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;
-;; Specifies the format for fully outputted dates. Defaults to RFC1123
-;; Special supported values are ANSIC, UnixDate, RubyDate, RFC822, RFC822Z, RFC850, RFC1123, RFC1123Z, RFC3339, RFC3339Nano, Kitchen, Stamp, StampMilli, StampMicro and StampNano
-;; For more information about the format see http://golang.org/pkg/time/#pkg-constants
-;FORMAT =
-;;
 ;; Location the UI time display i.e. Asia/Shanghai
 ;; Empty means server's location setting
 ;DEFAULT_UI_LOCATION =
diff --git a/docs/content/doc/administration/config-cheat-sheet.en-us.md b/docs/content/doc/administration/config-cheat-sheet.en-us.md
index 03cd93f91eba2..f637b1ebd8132 100644
--- a/docs/content/doc/administration/config-cheat-sheet.en-us.md
+++ b/docs/content/doc/administration/config-cheat-sheet.en-us.md
@@ -1207,7 +1207,6 @@ in this mapping or the filetype using heuristics.
 
 ## Time (`time`)
 
-- `FORMAT`: Time format to display on UI. i.e. RFC1123 or 2006-01-02 15:04:05
 - `DEFAULT_UI_LOCATION`: Default location of time on the UI, so that we can display correct user's time on UI. i.e. Asia/Shanghai
 
 ## Task (`task`)
diff --git a/modules/setting/time.go b/modules/setting/time.go
index 5fd0fdb92f47b..7aea93ba27591 100644
--- a/modules/setting/time.go
+++ b/modules/setting/time.go
@@ -10,44 +10,11 @@ import (
 )
 
 var (
-	// Time settings
-	TimeFormat string
 	// UILocation is the location on the UI, so that we can display the time on UI.
 	DefaultUILocation = time.Local
 )
 
 func loadTimeFrom(rootCfg ConfigProvider) {
-	timeFormatKey := rootCfg.Section("time").Key("FORMAT").MustString("")
-	if timeFormatKey != "" {
-		TimeFormat = map[string]string{
-			"ANSIC":       time.ANSIC,
-			"UnixDate":    time.UnixDate,
-			"RubyDate":    time.RubyDate,
-			"RFC822":      time.RFC822,
-			"RFC822Z":     time.RFC822Z,
-			"RFC850":      time.RFC850,
-			"RFC1123":     time.RFC1123,
-			"RFC1123Z":    time.RFC1123Z,
-			"RFC3339":     time.RFC3339,
-			"RFC3339Nano": time.RFC3339Nano,
-			"Kitchen":     time.Kitchen,
-			"Stamp":       time.Stamp,
-			"StampMilli":  time.StampMilli,
-			"StampMicro":  time.StampMicro,
-			"StampNano":   time.StampNano,
-		}[timeFormatKey]
-		// When the TimeFormatKey does not exist in the previous map e.g.'2006-01-02 15:04:05'
-		if len(TimeFormat) == 0 {
-			TimeFormat = timeFormatKey
-			TestTimeFormat, _ := time.Parse(TimeFormat, TimeFormat)
-			if TestTimeFormat.Format(time.RFC3339) != "2006-01-02T15:04:05Z" {
-				log.Warn("Provided TimeFormat: %s does not create a fully specified date and time.", TimeFormat)
-				log.Warn("In order to display dates and times correctly please check your time format has 2006, 01, 02, 15, 04 and 05")
-			}
-			log.Trace("Custom TimeFormat: %s", TimeFormat)
-		}
-	}
-
 	zone := rootCfg.Section("time").Key("DEFAULT_UI_LOCATION").String()
 	if zone != "" {
 		var err error
diff --git a/modules/timeutil/language.go b/modules/timeutil/language.go
deleted file mode 100644
index c2f7a0e579339..0000000000000
--- a/modules/timeutil/language.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2019 The Gitea Authors. All rights reserved.
-// SPDX-License-Identifier: MIT
-
-package timeutil
-
-import (
-	"time"
-
-	"code.gitea.io/gitea/modules/setting"
-)
-
-var langTimeFormats = map[string]string{
-	"zh-CN": "2006年01月02日 15时04分05秒",
-	"en-US": time.RFC1123,
-	"lv-LV": "02.01.2006. 15:04:05",
-}
-
-// GetLangTimeFormat represents the default time format for the language
-func GetLangTimeFormat(lang string) string {
-	return langTimeFormats[lang]
-}
-
-// GetTimeFormat represents the
-func GetTimeFormat(lang string) string {
-	if setting.TimeFormat == "" {
-		format := GetLangTimeFormat(lang)
-		if format == "" {
-			format = time.RFC1123
-		}
-		return format
-	}
-	return setting.TimeFormat
-}

From 931136b06a6aaf76d180464eac19c9ba30209487 Mon Sep 17 00:00:00 2001
From: Yarden Shoham <git@yardenshoham.com>
Date: Sat, 29 Apr 2023 17:21:45 +0000
Subject: [PATCH 2/3] fmt

---
 modules/setting/time.go | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/modules/setting/time.go b/modules/setting/time.go
index 7aea93ba27591..4e6cf5d75f937 100644
--- a/modules/setting/time.go
+++ b/modules/setting/time.go
@@ -9,10 +9,8 @@ import (
 	"code.gitea.io/gitea/modules/log"
 )
 
-var (
-	// UILocation is the location on the UI, so that we can display the time on UI.
-	DefaultUILocation = time.Local
-)
+// UILocation is the location on the UI, so that we can display the time on UI.
+var DefaultUILocation = time.Local
 
 func loadTimeFrom(rootCfg ConfigProvider) {
 	zone := rootCfg.Section("time").Key("DEFAULT_UI_LOCATION").String()

From 6a2f74a8d2bbf2223a57e602ac423ba7d8805cef Mon Sep 17 00:00:00 2001
From: Yarden Shoham <git@yardenshoham.com>
Date: Sat, 29 Apr 2023 17:38:31 +0000
Subject: [PATCH 3/3] lint

---
 modules/setting/time.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/setting/time.go b/modules/setting/time.go
index 4e6cf5d75f937..6d2aa80f5bdb9 100644
--- a/modules/setting/time.go
+++ b/modules/setting/time.go
@@ -9,7 +9,7 @@ import (
 	"code.gitea.io/gitea/modules/log"
 )
 
-// UILocation is the location on the UI, so that we can display the time on UI.
+// DefaultUILocation is the location on the UI, so that we can display the time on UI.
 var DefaultUILocation = time.Local
 
 func loadTimeFrom(rootCfg ConfigProvider) {