Skip to content

Commit 2fede44

Browse files
committed
Cleanup TODOs, tweak avro docs.
1 parent 485805c commit 2fede44

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

schemas-analyze/src/main/java/org/cedar/schemas/analyze/DateInfo.java

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ public class DateInfo implements Comparable<DateInfo> {
2828
public final String utcDateTimeString;
2929
public final String endUtcDateTimeString;
3030
public final Long year;
31-
public Integer dayOfYear; // values 1 - 366 // TODO temp remove final from these fields, just to sanity check things
32-
public Integer dayOfMonth; // values 1 - 31
33-
public Integer month; // values 1 - 12
31+
public final Integer dayOfYear; // values 1 - 366
32+
public final Integer dayOfMonth; // values 1 - 31
33+
public final Integer month; // values 1 - 12
3434

35-
// special stuff for dealing with how we interpret year or month precision instants:
36-
public Integer endDayOfYear;
37-
public Integer endDayOfMonth;
38-
public Integer endMonth;
35+
// special stuff for dealing with how we interpret range, including instants with year or month precision instants:
36+
public final Integer endDayOfYear; // values 1 - 366
37+
public final Integer endDayOfMonth; // values 1 - 31
38+
public final Integer endMonth; // values 1 - 12
3939

4040
public DateInfo(String dateString, boolean start) {
4141
if (dateString == null || dateString.length() == 0) {
@@ -49,6 +49,9 @@ public DateInfo(String dateString, boolean start) {
4949
dayOfYear = null;
5050
dayOfMonth = null;
5151
month = null;
52+
endDayOfYear = null;
53+
endDayOfMonth = null;
54+
endMonth = null;
5255
return;
5356
}
5457

@@ -61,30 +64,30 @@ public DateInfo(String dateString, boolean start) {
6164
} else {
6265
year = (long) yearValue;
6366
}
64-
dayOfYear = extractField(parsedDate, ChronoField.DAY_OF_YEAR);
65-
dayOfMonth = extractField(parsedDate, ChronoField.DAY_OF_MONTH);
66-
month = extractField(parsedDate, ChronoField.MONTH_OF_YEAR);
67-
if (parsedDate != null && dayOfMonth == null && month != null) { // TODO or parsedDate instanceof YearMonth
67+
Integer dayOfYearValue = extractField(parsedDate, ChronoField.DAY_OF_YEAR);
68+
Integer dayOfMonthValue = extractField(parsedDate, ChronoField.DAY_OF_MONTH);
69+
Integer monthValue = extractField(parsedDate, ChronoField.MONTH_OF_YEAR);
70+
if (parsedDate instanceof YearMonth) {
71+
month = monthValue;
6872
endMonth = month;
6973
dayOfMonth = 1;
7074
endDayOfMonth = ((YearMonth)parsedDate).lengthOfMonth();
7175
dayOfYear = ((YearMonth)parsedDate).atDay(1).getDayOfYear();
7276
endDayOfYear = ((YearMonth)parsedDate).atEndOfMonth().getDayOfYear();
73-
// endUtcDateTimeString = utcDateTimeString(((YearMonth)parsedDate).atEndOfMonth(), false);
74-
} else if (parsedDate != null && month == null && year != null) { // TODO or instanceof Year?
77+
} else if (parsedDate instanceof Year) {
7578
dayOfMonth = 1;
7679
dayOfYear = 1;
7780
endDayOfYear = ((Year)parsedDate).length(); // number of days in the year, including leap years
7881
endDayOfMonth = 31;
7982
month = 1;
8083
endMonth = 12;
81-
82-
// endUtcDateTimeString = utcDateTimeString(((Year)parsedDate).atDay(endDayOfYear), false);
8384
} else {
85+
dayOfYear = dayOfYearValue;
86+
dayOfMonth = dayOfMonthValue;
87+
month = monthValue;
8488
endMonth = month;
8589
endDayOfMonth = dayOfMonth;
8690
endDayOfYear = dayOfYear;
87-
// endUtcDateTimeString = utcDateTimeString;
8891
}
8992

9093
if (longDate != null && !indexable(longDate)) {

schemas-core/src/main/resources/avro/psi/analysis.avsc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@
495495
"string"
496496
],
497497
"default": null,
498-
"doc": "If possible, a full ISO-8601 formatted date time string in the UTC time zone for the analyzed instant value. If instantPrecision does not include time, day, or month, the value is the assumed date time the instant ends, e.g. the last day of a month or year"
498+
"doc": "If possible, a full ISO-8601 formatted date time string in the UTC time zone for the end analyzed instant value. The actual or assumed end date time based on precision of original data"
499499
},
500500
{
501501
"name": "instantYear",
@@ -522,7 +522,7 @@
522522
"int"
523523
],
524524
"default": null,
525-
"doc": "If instantPrecision does not include day, an integer indicating the assumed day of year the instant ends, e.g. the last day of a month or year"
525+
"doc": "An integer indicating the actual or assumed day of year the instant ends depending on the precision of the original content, e.g. the last day of a month or year."
526526
},
527527
{
528528
"name": "instantDayOfMonth",
@@ -540,7 +540,7 @@
540540
"int"
541541
],
542542
"default": null,
543-
"doc": "If instantPrecision does not include day, an integer indicating the assumed day of month the instant ends, e.g. the last day of a month or year"
543+
"doc": "An integer indicating the actual or assumed day of month the instant ends depending on precision, e.g. the last day of a month or year"
544544
},
545545
{
546546
"name": "instantMonth",

0 commit comments

Comments
 (0)