Project

General

Profile

Take locale into account in a macro

Added by Sergei Naumov 3 months ago

Hi!
I need to display a due date for an issue in my macro. Using

link_to_issue(issue, :subject => false, :tracker => false) +  ", #{issue.due_date}" 

works but the date is displayed in a format YYYY-MM-DD which does not take into account the locate set in Redmine settings (based on language it should be DD-MM-YYYY). How do I correct for this?


Replies (2)

RE: Take locale into account in a macro - Added by Holger Just 3 months ago

Redmine::I18n (which is available in all normal controller and view contexts by default) provides a format_date method which returns the goiven date as a formatted string according to the current user's locale. Your code could thus be adapted to

link_to_issue(issue, :subject => false, :tracker => false) +  ", #{format_date(issue.due_date)}" 

RE: Take locale into account in a macro - Added by Sergei Naumov 3 months ago

Holger Just wrote in RE: Take locale into account in a macro:

Redmine::I18n (which is available in all normal controller and view contexts by default) provides a format_date method which returns the goiven date as a formatted string according to the current user's locale. Your code could thus be adapted to

[...]

Thanks

    (1-2/2)