Skip to content

Commit fc9553c

Browse files
committed
now conditionally show schedules based on date
1 parent 15a266f commit fc9553c

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

bin/comp110/Parser.class

368 Bytes
Binary file not shown.

src/comp110/Parser.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88
import java.io.FileReader;
99
import java.io.IOException;
1010
import java.util.ArrayList;
11+
import java.util.Calendar;
12+
import java.util.Date;
1113
import java.util.List;
1214
import java.util.Scanner;
1315
import com.google.gson.Gson;
1416
import java.io.PrintWriter;
17+
import java.text.DateFormat;
18+
import java.time.Year;
1519

1620
/* Created by Keith Whitley */
1721

@@ -153,15 +157,15 @@ public List<Schedule> parseSchedules(String scheduleFolderPath, String staff_dir
153157
}
154158
}
155159
Leads leads = this.parseLeads(leadsFile, staff);
156-
schedules.add(new Schedule(staff, week, leads,
157-
scheduleJson.getName().substring(9, scheduleJson.getName().length()).split("\\.")[0])); // grab
158-
// just
159-
// the
160-
// date
161-
// portion
162-
// of
163-
// file
164-
// name
160+
String scheduleDateRange = scheduleJson.getName().substring(9, scheduleJson.getName().length()).split("\\.")[0]; // grab just date of file name
161+
// need to -1 on month field because it is zero indexed
162+
// https://stackoverflow.com/questions/45996752/calendar-getcalendar-year-returns-wrong-year
163+
Date startDate = new Date(Year.now().getValue() - 1900, Integer.parseInt(scheduleDateRange.substring(0, 2)) - 1, Integer.parseInt(scheduleDateRange.substring(3, 5)));
164+
Date endDate = new Date(Year.now().getValue() - 1900, Integer.parseInt(scheduleDateRange.substring(6, 8)) - 1, Integer.parseInt(scheduleDateRange.substring(9, 11)));
165+
if (!new Date().after(endDate)) { // new date is current date time
166+
schedules.add(new Schedule(staff, week, leads, scheduleDateRange));
167+
}
168+
165169
}
166170

167171
if (schedules.size() == 0) {

src/ui/UI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class UI extends Application {
3535
private ScheduleStage _scheduleStage;
3636
private ViewSwapsStage _viewSwapsStage;
3737

38-
private static final String VERSION = "0.3.1";
38+
private static final String VERSION = "0.4.0";
3939

4040

4141
@Override

0 commit comments

Comments
 (0)