Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calendar API cleanup #4201

Merged
merged 155 commits into from
Jan 9, 2024
Merged

Calendar API cleanup #4201

merged 155 commits into from
Jan 9, 2024

Conversation

chipkent
Copy link
Member

@chipkent chipkent commented Jul 18, 2023

The calendar API is a key part of the time library that was never modernized. This PR cleans up the user-facing calendar libraries:

  1. Use new Java time types as the primary types.
  2. Consistently and intelligently name all functions and classes.
  3. Add missing functionality.
  4. Support user-defined business calendars.
  5. Provide basic example calendars.
  6. Remove python methods that are likely to result in poor query performance because of accidental use.
  7. Support conversions to numpy business calendars.

Many of the above changes are breaking. The prior library in DHC was not popularized because this API rework had not been completed. Hopefully, this means the number of impacted users is small.

The underlying library has >90% test coverage.

The Calendar XML configuration format has been changed to:

 <calendar>
     <name>USNYSE</name>
     <description>New York Stock Exchange Calendar</description>
     <timeZone>America/New_York</timeZone>
     <default>
          <businessTime><open>09:30</open><close>16:00</close></businessTime>
          <weekend>Saturday</weekend>
          <weekend>Sunday</weekend>
      </default>
      <firstValidDate>1999-01-01</firstValidDate>
      <lastValidDate>2003-12-31</lastValidDate>
      <holiday>
          <date>19990101</date>
      </holiday>
      <holiday>
          <date>20020705</date>
          <businessTime>
              <open>09:30</open>
              <close>13:00</close>
          </businessTime>
      </holiday>
 </calendar>

* DefaultNoHolidayBusinessCalendar
* Calendar
* Calendar
* BusinessCalendar
* Calendar
* BusinessCalendar
* Calendar
* BusinessCalendar
* @return current date
*/
public LocalDate calendarDate() {
return DateTimeUtils.todayLocalDate(timeZone());
Copy link
Member

Choose a reason for hiding this comment

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

It's important context, but we are depending on the clock state in DateTimeUtils. I'm not the biggest fan of the static state in DateTimeUtils in-and-of itself, but I wonder if we should be persisting that stateful dependency here? Should clock be a member of Calendar?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not fully following this set of comments.

DateTimeUtils is the foundational layer. Calendar is built on top of DateTimeUtils. BusinessCalendar is built on top of Calendar. If Calendar has its own clock, separate from DateTimeUtils, it is just going to lead to user nightmare scenarios since we can't tell the user to just change the clock in a single place. Instead, they will end up with an inconsistent view of the world where they need to know multiple places they need to update to achieve consistency.

alexpeters1208
alexpeters1208 previously approved these changes Dec 15, 2023
Copy link
Contributor

@jmao-denver jmao-denver left a comment

Choose a reason for hiding this comment

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

The Python changes LGTM.

@chipkent chipkent merged commit ef44435 into deephaven:main Jan 9, 2024
19 checks passed
@chipkent chipkent deleted the cal_upgrades branch January 9, 2024 20:54
@github-actions github-actions bot locked and limited conversation to collaborators Jan 9, 2024
@deephaven-internal
Copy link
Contributor

Labels indicate documentation is required. Issues for documentation have been opened:

Community: https://github.com/deephaven/deephaven.io/issues/3610

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants