|
|
|
@@ -127,6 +127,8 @@ public class EventRepository {
|
|
|
|
|
|
|
|
|
|
|
|
JSONArray array = new JSONArray(json);
|
|
|
|
JSONArray array = new JSONArray(json);
|
|
|
|
List<EventItem> events = new ArrayList<>();
|
|
|
|
List<EventItem> events = new ArrayList<>();
|
|
|
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < array.length(); i++) {
|
|
|
|
for (int i = 0; i < array.length(); i++) {
|
|
|
|
JSONObject obj = array.getJSONObject(i);
|
|
|
|
JSONObject obj = array.getJSONObject(i);
|
|
|
|
String title = obj.optString("title");
|
|
|
|
String title = obj.optString("title");
|
|
|
|
@@ -135,8 +137,20 @@ public class EventRepository {
|
|
|
|
String status = obj.optString("status");
|
|
|
|
String status = obj.optString("status");
|
|
|
|
String link = obj.optString("link");
|
|
|
|
String link = obj.optString("link");
|
|
|
|
String normalized = normalizeLink(link);
|
|
|
|
String normalized = normalizeLink(link);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ajustar hora: la web muestra hora de España, Argentina es +2 horas
|
|
|
|
|
|
|
|
String displayTime = time;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (time != null && !time.isEmpty()) {
|
|
|
|
|
|
|
|
LocalTime localTime = LocalTime.parse(time.trim(), formatter);
|
|
|
|
|
|
|
|
LocalTime adjustedTime = localTime.plusHours(2);
|
|
|
|
|
|
|
|
displayTime = adjustedTime.format(formatter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DateTimeParseException ignored) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long startMillis = parseEventTime(time);
|
|
|
|
long startMillis = parseEventTime(time);
|
|
|
|
events.add(new EventItem(title, time, category, status, normalized, extractChannelName(link), startMillis));
|
|
|
|
events.add(new EventItem(title, displayTime, category, status, normalized, extractChannelName(link), startMillis));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Collections.unmodifiableList(events);
|
|
|
|
return Collections.unmodifiableList(events);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -167,9 +181,11 @@ public class EventRepository {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
|
|
|
LocalTime localTime = LocalTime.parse(time.trim(), formatter);
|
|
|
|
LocalTime localTime = LocalTime.parse(time.trim(), formatter);
|
|
|
|
|
|
|
|
// Ajustar hora: la web muestra hora de España, Argentina es +2 horas
|
|
|
|
|
|
|
|
LocalTime adjustedTime = localTime.plusHours(2);
|
|
|
|
ZoneId zone = ZoneId.of("America/Argentina/Buenos_Aires");
|
|
|
|
ZoneId zone = ZoneId.of("America/Argentina/Buenos_Aires");
|
|
|
|
LocalDate today = LocalDate.now(zone);
|
|
|
|
LocalDate today = LocalDate.now(zone);
|
|
|
|
ZonedDateTime start = ZonedDateTime.of(LocalDateTime.of(today, localTime), zone);
|
|
|
|
ZonedDateTime start = ZonedDateTime.of(LocalDateTime.of(today, adjustedTime), zone);
|
|
|
|
ZonedDateTime now = ZonedDateTime.now(zone);
|
|
|
|
ZonedDateTime now = ZonedDateTime.now(zone);
|
|
|
|
if (start.isBefore(now.minusHours(12))) {
|
|
|
|
if (start.isBefore(now.minusHours(12))) {
|
|
|
|
start = start.plusDays(1);
|
|
|
|
start = start.plusDays(1);
|
|
|
|
|