Added date and time to Feedback (#5797)

* Add Date and Time in UTC format to Feedback

* Add UTC date to the Subject instead of adding it to the body

* Change the UTC Date format to yyyy/MM/dd HH:mm:ss

* Minor changes

---------

Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
ujjwal2900 2024-09-13 11:09:02 +05:30 committed by GitHub
parent c3cd30ce5c
commit 9393dda9a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,6 +6,9 @@ import fr.free.nrw.commons.auth.AccountUtil;
import fr.free.nrw.commons.feedback.model.Feedback; import fr.free.nrw.commons.feedback.model.Feedback;
import fr.free.nrw.commons.utils.LangCodeUtils; import fr.free.nrw.commons.utils.LangCodeUtils;
import java.util.Locale; import java.util.Locale;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
/** /**
* Creates a wikimedia recognizable format * Creates a wikimedia recognizable format
@ -32,11 +35,19 @@ public class FeedbackContentCreator {
/* /*
* Construct the feedback section title * Construct the feedback section title
*/ */
//Get the UTC Date and Time and add it to the Title
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.ENGLISH);
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
final String UTC_FormattedDate = dateFormat.format(new Date());
sectionTitleBuilder = new StringBuilder(); sectionTitleBuilder = new StringBuilder();
sectionTitleBuilder.append("Feedback from "); sectionTitleBuilder.append("Feedback from ");
sectionTitleBuilder.append(AccountUtil.getUserName(context)); sectionTitleBuilder.append(AccountUtil.getUserName(context));
sectionTitleBuilder.append(" for version "); sectionTitleBuilder.append(" for version ");
sectionTitleBuilder.append(feedback.getVersion()); sectionTitleBuilder.append(feedback.getVersion());
sectionTitleBuilder.append(" on ");
sectionTitleBuilder.append(UTC_FormattedDate);
/* /*
* Construct the feedback section text * Construct the feedback section text
@ -96,6 +107,7 @@ public class FeedbackContentCreator {
} }
sectionTextBuilder.append("~~~~"); sectionTextBuilder.append("~~~~");
sectionTextBuilder.append("\n"); sectionTextBuilder.append("\n");
} }
public String getSectionText() { public String getSectionText() {