Skip to content

Commit

Permalink
[DatePicker] Make new public getter methods for start/end/openAt valu…
Browse files Browse the repository at this point in the history
…es with long return types for CalendarConstraints

Resolves #2907

PiperOrigin-RevId: 473053039
  • Loading branch information
imhappi authored and afohrman committed Sep 12, 2022
1 parent 02327c3 commit 6643695
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ public DateValidator getDateValidator() {

/** Returns the earliest month allowed by this set of bounds. */
@NonNull
public Month getStart() {
Month getStart() {
return start;
}

/** Returns the latest month allowed by this set of bounds. */
@NonNull
public Month getEnd() {
Month getEnd() {
return end;
}

Expand Down Expand Up @@ -138,6 +138,25 @@ int getYearSpan() {
return yearSpan;
}

/** Returns the earliest time in milliseconds allowed by this set of bounds. */
public long getStartMs() {
return start.timeInMillis;
}

/** Returns the latest time in milliseconds allowed by this set of bounds. */
public long getEndMs() {
return end.timeInMillis;
}

/**
* Returns the openAt time in milliseconds within this set of bounds. Returns null if not
* available.
*/
@Nullable
public Long getOpenAtMs() {
return openAt == null ? null : openAt.timeInMillis;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,28 @@ public void setEnd_succeeds() {

assertThat(calendarConstraints.getEnd().timeInMillis).isEqualTo(FEB_2016);
}

@Test
public void getStartMs_succeeds() {
CalendarConstraints calendarConstraints =
new CalendarConstraints.Builder().setStart(FEB_2016).build();

assertThat(calendarConstraints.getStartMs()).isEqualTo(FEB_2016);
}

@Test
public void getEndMs_succeeds() {
CalendarConstraints calendarConstraints =
new CalendarConstraints.Builder().setEnd(FEB_2016).build();

assertThat(calendarConstraints.getEndMs()).isEqualTo(FEB_2016);
}

@Test
public void getOpenAtMs_succeeds() {
CalendarConstraints calendarConstraints =
new CalendarConstraints.Builder().setOpenAt(FEB_2016).build();

assertThat(calendarConstraints.getOpenAtMs()).isEqualTo(FEB_2016);
}
}

1 comment on commit 6643695

@ArcherEmiya05
Copy link

@ArcherEmiya05 ArcherEmiya05 commented on 6643695 Oct 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return milliseconds seems different from what is provided from setter. Here is the issue #3052

Please sign in to comment.