Skip to content

Commit

Permalink
Address review comments. Regenerate and format.
Browse files Browse the repository at this point in the history
  • Loading branch information
chipkent committed Dec 5, 2023
1 parent 4475018 commit 6c87ed0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ private YearData getYearData(final int year) {
* @param holidays holidays
*/
public BusinessCalendar(final String name, final String description, final ZoneId timeZone,
final LocalDate firstValidDate, final LocalDate lastValidDate,
final CalendarDay<LocalTime> standardBusinessDay, final Set<DayOfWeek> weekendDays,
final Map<LocalDate, CalendarDay<Instant>> holidays) {
final LocalDate firstValidDate, final LocalDate lastValidDate,
final CalendarDay<LocalTime> standardBusinessDay, final Set<DayOfWeek> weekendDays,
final Map<LocalDate, CalendarDay<Instant>> holidays) {
super(name, description, timeZone);
this.firstValidDate = firstValidDate;
this.lastValidDate = lastValidDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import java.util.*;

/**
* Schedule for a single calendar day. The schedule contains a list of business time ranges, which are the ranges of time
* during which businesses are open.
* Schedule for a single calendar day. The schedule contains a list of business time ranges, which are the ranges of
* time during which businesses are open.
*
* A business day may contain multiple business time ranges. For example, some financial exchanges have a morning and an
* afternoon trading session. This would be represented by a business day with two business time ranges.
Expand Down Expand Up @@ -97,12 +97,12 @@ public T businessStart() {
* @return end of the business day, or null for a holiday schedule
*/
public T businessEnd() {
return !businessTimeRanges.isEmpty() ? businessTimeRanges.get(businessTimeRanges.size()-1).end() : null;
return !businessTimeRanges.isEmpty() ? businessTimeRanges.get(businessTimeRanges.size() - 1).end() : null;
}

/**
* Gets the length of the business day in nanoseconds. If the business day has multiple business time ranges,
* only the time during the ranges is counted.
* Gets the length of the business day in nanoseconds. If the business day has multiple business time ranges, only
* the time during the ranges is counted.
*
* @return length of the day in nanoseconds
*/
Expand Down Expand Up @@ -172,8 +172,10 @@ public boolean isBusinessTime(final T time) {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof CalendarDay)) return false;
if (this == o)
return true;
if (!(o instanceof CalendarDay))
return false;
CalendarDay<?> that = (CalendarDay<?>) o;
return Objects.equals(businessTimeRanges, that.businessTimeRanges);
}
Expand All @@ -199,7 +201,7 @@ public String toString() {
* @return new business schedule in the specified date and time zone
*/
public static CalendarDay<Instant> toInstant(final CalendarDay<LocalTime> s, final LocalDate date,
final ZoneId timeZone) {
final ZoneId timeZone) {
// noinspection unchecked
return new CalendarDay<>(s.businessTimeRanges().stream().map(p -> TimeRange.toInstant(p, date, timeZone))
.toArray(TimeRange[]::new));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@

package io.deephaven.time.calendar;

import io.deephaven.time.calendar.BusinessCalendar;
import io.deephaven.time.calendar.Calendar;
import io.deephaven.time.calendar.CalendarDay;
import java.lang.String;
import java.time.DayOfWeek;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.Set;

/**
* Static versions of business calendar methods that use the default business calendar.
Expand Down Expand Up @@ -43,21 +53,6 @@ public class StaticCalendarMethods {
/** @see io.deephaven.time.calendar.BusinessCalendar#businessDates(java.time.ZonedDateTime,java.time.ZonedDateTime,boolean,boolean) */
public static java.time.LocalDate[] businessDates( java.time.ZonedDateTime start, java.time.ZonedDateTime end, boolean startInclusive, boolean endInclusive ) {return Calendars.calendar().businessDates( start, end, startInclusive, endInclusive );}

/** @see io.deephaven.time.calendar.BusinessCalendar#calendarDay() */
public static CalendarDay<Instant> businessDay( ) {return Calendars.calendar().calendarDay( );}

/** @see io.deephaven.time.calendar.BusinessCalendar#calendarDay(java.lang.String) */
public static CalendarDay<Instant> businessDay(java.lang.String date ) {return Calendars.calendar().calendarDay( date );}

/** @see io.deephaven.time.calendar.BusinessCalendar#calendarDay(java.time.Instant) */
public static CalendarDay<Instant> businessDay(java.time.Instant time ) {return Calendars.calendar().calendarDay( time );}

/** @see io.deephaven.time.calendar.BusinessCalendar#calendarDay(java.time.LocalDate) */
public static CalendarDay<Instant> businessDay(java.time.LocalDate date ) {return Calendars.calendar().calendarDay( date );}

/** @see io.deephaven.time.calendar.BusinessCalendar#calendarDay(java.time.ZonedDateTime) */
public static CalendarDay<Instant> businessDay(java.time.ZonedDateTime time ) {return Calendars.calendar().calendarDay( time );}

/** @see io.deephaven.time.calendar.Calendar#calendarDate() */
public static java.time.LocalDate calendarDate( ) {return Calendars.calendar().calendarDate( );}

Expand Down Expand Up @@ -85,6 +80,21 @@ public class StaticCalendarMethods {
/** @see io.deephaven.time.calendar.Calendar#calendarDates(java.time.ZonedDateTime,java.time.ZonedDateTime,boolean,boolean) */
public static java.time.LocalDate[] calendarDates( java.time.ZonedDateTime start, java.time.ZonedDateTime end, boolean startInclusive, boolean endInclusive ) {return Calendars.calendar().calendarDates( start, end, startInclusive, endInclusive );}

/** @see io.deephaven.time.calendar.BusinessCalendar#calendarDay() */
public static io.deephaven.time.calendar.CalendarDay<java.time.Instant> calendarDay( ) {return Calendars.calendar().calendarDay( );}

/** @see io.deephaven.time.calendar.BusinessCalendar#calendarDay(java.lang.String) */
public static io.deephaven.time.calendar.CalendarDay<java.time.Instant> calendarDay( java.lang.String date ) {return Calendars.calendar().calendarDay( date );}

/** @see io.deephaven.time.calendar.BusinessCalendar#calendarDay(java.time.Instant) */
public static io.deephaven.time.calendar.CalendarDay<java.time.Instant> calendarDay( java.time.Instant time ) {return Calendars.calendar().calendarDay( time );}

/** @see io.deephaven.time.calendar.BusinessCalendar#calendarDay(java.time.LocalDate) */
public static io.deephaven.time.calendar.CalendarDay<java.time.Instant> calendarDay( java.time.LocalDate date ) {return Calendars.calendar().calendarDay( date );}

/** @see io.deephaven.time.calendar.BusinessCalendar#calendarDay(java.time.ZonedDateTime) */
public static io.deephaven.time.calendar.CalendarDay<java.time.Instant> calendarDay( java.time.ZonedDateTime time ) {return Calendars.calendar().calendarDay( time );}

/** @see io.deephaven.time.calendar.Calendar#dayOfWeek() */
public static int calendarDayOfWeek( ) {return Calendars.calendar().dayOfWeek( );}

Expand Down Expand Up @@ -167,7 +177,7 @@ public class StaticCalendarMethods {
public static java.time.LocalDate futureNonBusinessDate( int days ) {return Calendars.calendar().futureNonBusinessDate( days );}

/** @see io.deephaven.time.calendar.BusinessCalendar#holidays() */
public static java.util.Map<java.time.LocalDate, CalendarDay<Instant>> holidays( ) {return Calendars.calendar().holidays( );}
public static java.util.Map<java.time.LocalDate, io.deephaven.time.calendar.CalendarDay<java.time.Instant>> holidays( ) {return Calendars.calendar().holidays( );}

/** @see io.deephaven.time.calendar.BusinessCalendar#isBusinessDay() */
public static boolean isBusinessDay( ) {return Calendars.calendar().isBusinessDay( );}
Expand Down Expand Up @@ -410,7 +420,7 @@ public class StaticCalendarMethods {
public static java.time.ZonedDateTime plusNonBusinessDays( java.time.ZonedDateTime time, int days ) {return Calendars.calendar().plusNonBusinessDays( time, days );}

/** @see io.deephaven.time.calendar.BusinessCalendar#standardBusinessDay() */
public static CalendarDay<LocalTime> standardBusinessDay( ) {return Calendars.calendar().standardBusinessDay( );}
public static io.deephaven.time.calendar.CalendarDay<java.time.LocalTime> standardBusinessDay( ) {return Calendars.calendar().standardBusinessDay( );}

/** @see io.deephaven.time.calendar.BusinessCalendar#standardBusinessNanos() */
public static long standardBusinessNanos( ) {return Calendars.calendar().standardBusinessNanos( );}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public String toString() {
* @return new time range in the specified date and time zone
*/
public static TimeRange<Instant> toInstant(final TimeRange<LocalTime> p, final LocalDate date,
final ZoneId timeZone) {
final ZoneId timeZone) {
return new TimeRange<>(DateTimeUtils.toInstant(date, p.start, timeZone),
DateTimeUtils.toInstant(date, p.end, timeZone));
}
Expand Down

0 comments on commit 6c87ed0

Please sign in to comment.