Merge branch 'dev' of https://gitlab.com/romanov73/ng-tracker into 98-project-tasks

This commit is contained in:
Васин Антон 2019-05-28 16:17:37 +03:00
commit e967e2bfee

View File

@ -3,6 +3,7 @@ package ru.ulstu.utils.timetable;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import ru.ulstu.core.util.DateUtils;
import ru.ulstu.utils.timetable.errors.TimetableClientException; import ru.ulstu.utils.timetable.errors.TimetableClientException;
import ru.ulstu.utils.timetable.model.Lesson; import ru.ulstu.utils.timetable.model.Lesson;
import ru.ulstu.utils.timetable.model.TimetableResponse; import ru.ulstu.utils.timetable.model.TimetableResponse;
@ -50,9 +51,15 @@ public class TimetableService {
} }
private int getCurrentWeek() { private int getCurrentWeek() {
Calendar cal = Calendar.getInstance(); Date currentDate = Calendar.getInstance().getTime();
cal.setTime(new Date()); currentDate = DateUtils.clearTime(currentDate);
return (cal.get(Calendar.WEEK_OF_YEAR) + 1) % 2;
Calendar firstJan = Calendar.getInstance();
firstJan.set(Calendar.MONTH, 0);
firstJan.set(Calendar.DAY_OF_MONTH, 1);
return (int) Math.round(Math.ceil((((currentDate.getTime() - firstJan.getTime().getTime()) / 86400000)
+ DateUtils.addDays(firstJan.getTime(), 1).getTime() / 7) % 2));
} }
private TimetableResponse getTimetableForUser(String userFIO) throws RestClientException { private TimetableResponse getTimetableForUser(String userFIO) throws RestClientException {