Skip to content

Conversation

@Ahed91
Copy link
Contributor

@Ahed91 Ahed91 commented Jan 30, 2017

I need to use custom time format in `conf/app.ini' like

[time]
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://stackoverflow.com/a/20234207/2570425

PS: First GO commit

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://stackoverflow.com/a/20234207/2570425> 

PS: First GO commit
@lunny lunny added this to the 1.1.0 milestone Jan 30, 2017
@lunny lunny added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Jan 30, 2017
"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 == "") {
Copy link
Member

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.

Copy link
Contributor Author

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")

Copy link
Contributor Author

@Ahed91 Ahed91 Jan 30, 2017

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 ""

Copy link
Member

@lunny lunny Jan 30, 2017

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.

Copy link
Contributor Author

@Ahed91 Ahed91 Jan 30, 2017

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>

}[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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs validation.

@lunny
Copy link
Member

lunny commented Feb 4, 2017

LGTM

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 4, 2017
@appleboy
Copy link
Member

appleboy commented Feb 4, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 4, 2017
@lunny lunny merged commit 49fa03b into go-gitea:master Feb 4, 2017
@Ahed91 Ahed91 deleted the patch-1 branch February 4, 2017 15:12
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants