implemented editor for times
This commit is contained in:
@@ -108,12 +108,21 @@ public class Time implements Mappable{
|
||||
);
|
||||
}
|
||||
|
||||
private LocalDateTime parse(String time){
|
||||
if (time.contains("T")) return LocalDateTime.parse(time);
|
||||
return LocalDateTime.parse(time,DT);
|
||||
}
|
||||
|
||||
public Time patch(JSONObject json) {
|
||||
if (json.has(SUBJECT) && json.get(SUBJECT) instanceof String s) subject = s;
|
||||
if (json.has(DESCRIPTION) && json.get(DESCRIPTION) instanceof String d) description = d;
|
||||
if (json.has(START_TIME) && json.get(START_TIME) instanceof String st) start = LocalDateTime.parse(st, DT);
|
||||
if (json.has(END_TIME) && json.get(END_TIME) instanceof String e) end = LocalDateTime.parse(e,DT);
|
||||
if (end != null && !start.isBefore(end)) throw UmbrellaException.invalidFieldException(END_TIME,"after start_time");
|
||||
if (json.has(DESCRIPTION)) {
|
||||
var o = json.get(DESCRIPTION);
|
||||
if (o instanceof JSONObject nested && nested.get(SOURCE) instanceof String src) o = src;
|
||||
if (o instanceof String d) description = d;
|
||||
}
|
||||
if (json.has(START_TIME) && json.get(START_TIME) instanceof String st) start = parse(st);
|
||||
if (json.has(END_TIME) && json.get(END_TIME) instanceof String e) end = parse(e);
|
||||
if (end != null && end.isBefore(start)) throw UmbrellaException.invalidFieldException(END_TIME,"after start_time");
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user