Skip to content

Commit e4c7e4b

Browse files
Use new DateWrapper method
1 parent cf4781e commit e4c7e4b

3 files changed

Lines changed: 3 additions & 10 deletions

File tree

app/src/main/java/org/schabi/newpipe/local/feed/FeedDatabaseManager.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ class FeedDatabaseManager(context: Context) {
7474

7575
fun upsertAll(subscriptionId: Long, items: List<StreamInfoItem>) {
7676
val oldestAllowedDate = LocalDate.now().minusWeeks(13)
77-
val zoneId = ZoneId.systemDefault()
7877
val itemsToInsert = items.filter {
79-
val uploadDate = it.uploadDate?.let { LocalDate.ofInstant(it.instant, zoneId) }
78+
val uploadDate = it.uploadDate?.localDateTime?.toLocalDate()
8079

8180
(uploadDate == null && it.streamType == StreamType.LIVE_STREAM) ||
8281
(uploadDate != null && uploadDate >= oldestAllowedDate)

app/src/main/java/org/schabi/newpipe/local/feed/service/FeedLoadManager.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import org.schabi.newpipe.util.ExtractorHelper.getChannelTab
2929
import org.schabi.newpipe.util.ExtractorHelper.getMoreChannelTabItems
3030
import java.time.Instant
3131
import java.time.LocalDate
32-
import java.time.ZoneId
3332
import java.util.concurrent.atomic.AtomicBoolean
3433
import java.util.concurrent.atomic.AtomicInteger
3534

@@ -320,13 +319,12 @@ class FeedLoadManager(private val context: Context) {
320319
}
321320

322321
private fun filterNewStreams(list: List<StreamInfoItem>): List<StreamInfoItem> {
323-
val zoneId = ZoneId.systemDefault()
324322
val oldestAllowedDate = LocalDate.now().minusWeeks(13)
325323
return list.filter {
326324
// Streams older than this date are automatically removed from the feed.
327325
// Therefore, streams which are not in the database,
328326
// but older than this date, are considered old.
329-
val date = it.uploadDate?.let { LocalDate.ofInstant(it.instant, zoneId) }
327+
val date = it.uploadDate?.localDateTime?.toLocalDate()
330328
!feedDatabaseManager.doesStreamExist(it) && date != null && date > oldestAllowedDate
331329
}
332330
}

app/src/main/java/org/schabi/newpipe/util/Localization.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,13 @@
3434
import java.math.RoundingMode;
3535
import java.text.NumberFormat;
3636
import java.time.Instant;
37-
import java.time.LocalDate;
38-
import java.time.ZoneId;
3937
import java.time.format.DateTimeFormatter;
4038
import java.time.format.FormatStyle;
4139
import java.util.Arrays;
4240
import java.util.List;
4341
import java.util.Locale;
4442
import java.util.stream.Collectors;
4543

46-
4744
/*
4845
* Created by chschtsch on 12/29/15.
4946
*
@@ -132,9 +129,8 @@ public static String localizeNumber(final double number) {
132129

133130
@NonNull
134131
public static String formatDate(@NonNull final DateWrapper dateWrapper) {
135-
final var localDate = LocalDate.ofInstant(dateWrapper.getInstant(), ZoneId.systemDefault());
136132
return DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).withLocale(getAppLocale())
137-
.format(localDate);
133+
.format(dateWrapper.getLocalDateTime());
138134
}
139135

140136
public static String localizeViewCount(@NonNull final Context context, final long viewCount) {

0 commit comments

Comments
 (0)