1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-08-29 09:02:19 +00:00

Merge pull request #4921 from Isira-Seneviratne/Call_offsetDateTime_instead_of_date

Call DateWrapper's offsetDateTime() instead of date().
This commit is contained in:
Tobias Groza
2020-11-20 15:58:22 +01:00
committed by GitHub
3 changed files with 7 additions and 5 deletions

View File

@@ -144,7 +144,8 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder {
}
if (item.getUploadDate() != null) {
itemPublishedTime.setText(Localization.relativeTime(item.getUploadDate().date()));
itemPublishedTime.setText(Localization.relativeTime(item.getUploadDate()
.offsetDateTime()));
} else {
itemPublishedTime.setText(item.getTextualUploadDate());
}

View File

@@ -95,7 +95,7 @@ public class StreamInfoItemHolder extends StreamMiniInfoItemHolder {
private String getFormattedRelativeUploadDate(final StreamInfoItem infoItem) {
if (infoItem.getUploadDate() != null) {
String formattedRelativeTime = Localization
.relativeTime(infoItem.getUploadDate().date());
.relativeTime(infoItem.getUploadDate().offsetDateTime());
if (DEBUG && PreferenceManager.getDefaultSharedPreferences(itemBuilder.getContext())
.getBoolean(itemBuilder.getContext()

View File

@@ -30,6 +30,7 @@ import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Arrays;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Locale;
@@ -312,12 +313,12 @@ public final class Localization {
prettyTime.removeUnit(Decade.class);
}
private static PrettyTime getPrettyTime() {
return prettyTime;
public static String relativeTime(final OffsetDateTime offsetDateTime) {
return relativeTime(GregorianCalendar.from(offsetDateTime.toZonedDateTime()));
}
public static String relativeTime(final Calendar calendarTime) {
return getPrettyTime().formatUnrounded(calendarTime);
return prettyTime.formatUnrounded(calendarTime);
}
private static void changeAppLanguage(final Locale loc, final Resources res) {