Skip to content

Commit

Permalink
Call DateWrapper's offsetDateTime() instead of date().
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne committed Nov 19, 2020
1 parent 493e47f commit eb1cddd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ public void updateFromItem(final InfoItem infoItem,
}

if (item.getUploadDate() != null) {
itemPublishedTime.setText(Localization.relativeTime(item.getUploadDate().date()));
itemPublishedTime.setText(Localization.relativeTime(item.getUploadDate()
.offsetDateTime()));
} else {
itemPublishedTime.setText(item.getTextualUploadDate());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private String getStreamInfoDetailLine(final StreamInfoItem infoItem) {
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()
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/org/schabi/newpipe/util/Localization.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
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;

Expand Down Expand Up @@ -312,12 +313,12 @@ private static void initPrettyTime(final Context context) {
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) {
Expand Down

0 comments on commit eb1cddd

Please sign in to comment.