-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow using custom time format #798
Conversation
I need to use custom time format in `conf/app.ini' like FORMAT = 2006-01-02 15:04:05 so that Gitea will display '2017-01-30 08:41:49' check this answer for more constants to format date <http:https://stackoverflow.com/a/20234207/2570425> PS: First GO commit
modules/setting/setting.go
Outdated
@@ -749,6 +749,11 @@ please consider changing to GITEA_CUSTOM`) | |||
"StampMicro": time.StampMicro, | |||
"StampNano": time.StampNano, | |||
}[Cfg.Section("time").Key("FORMAT").MustString("RFC1123")] | |||
// Determine When using custom time format like '2006-01-02 15:04:05' | |||
if (TimeFormat == "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MustString("RFC1123")
means default is RFC1123
, so TimeFormat
will never be empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No .. this is not assignment to TimeFormat e.g. `TimeFormat = Cfg.Section("time").Key("FORMAT").MustString("RFC1123")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the key Cfg.Section("time").Key("FORMAT").MustString("RFC1123")
was not present in the map. TimeFormat will be ""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cfg.Section("time").Key("FORMAT").MustString("RFC1123")
will always return a string, will never be empty. And RFC1123
is in the map, so TimeFormat
will never be empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok forget my comments for now --> that's the problem which prevents me from using custom time format ..
in my conf/app.ini
[time]
FORMAT = 2006-01-02 15:04:05
this FORMAT is not in the map ... so TIMEFORMAT
will be empty ..
this code will save 2006-01-02 15:04:05
in TIMEFORMAT
so when using function like TimeSince will return
<span class="time-since poping up" title="" data-content="2017-01-30 11:56:19" data-variation="inverted tiny">5 ساعات مضت</span>
instead of
<span class="time-since poping up" title="" data-content="" data-variation="inverted tiny">5 ساعات مضت</span>
modules/setting/setting.go
Outdated
@@ -749,6 +749,11 @@ please consider changing to GITEA_CUSTOM`) | |||
"StampMicro": time.StampMicro, | |||
"StampNano": time.StampNano, | |||
}[Cfg.Section("time").Key("FORMAT").MustString("RFC1123")] | |||
// Determine When using custom time format like '2006-01-02 15:04:05' | |||
if (TimeFormat == "") { | |||
TimeFormat = Cfg.Section("time").Key("FORMAT").String() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs validation.
LGTM |
LGTM |
I need to use custom time format in `conf/app.ini' like
so that Gitea will display '2017-01-30 08:41:49'
check this answer for more constants to format date http:https://stackoverflow.com/a/20234207/2570425
PS: First GO commit