1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +00:00

Call DateWrapper's offsetDateTime() instead of date().

This commit is contained in:
Isira Seneviratne 2020-11-19 18:35:17 +05:30
parent 493e47f7e6
commit eb1cddd85a
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) {