Skip to content

Conversation

@solodkiy
Copy link
Contributor

Converting LocalDateRange to Interval is a common task in my app. Typically, I have a method to generate reports that expects a LocalDateRange argument. Subsequently, I need to transform it for SQL queries using the BETWEEN operator. It’s important to note that the timezone in my database differs from the implied timezone in LocalDateRange.

The new method introduced will transform any LocalDateRange into an Interval in the specified timezone.

@solodkiy solodkiy force-pushed the LocalDateRange_toInterval branch 2 times, most recently from a81d95d to 3517451 Compare September 30, 2023 16:10
@solodkiy solodkiy force-pushed the LocalDateRange_toInterval branch from 3517451 to 4b22406 Compare September 30, 2023 16:12
Comment on lines +247 to +252
/**
* Converts this LocalDateRange to Interval instance.
*
* The result is Interval from 00:00 start date and 00:00 end date + one day (because end in Interval is exclude)
* in the given time-zone.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/**
* Converts this LocalDateRange to Interval instance.
*
* The result is Interval from 00:00 start date and 00:00 end date + one day (because end in Interval is exclude)
* in the given time-zone.
*/
/**
* Converts this LocalDateRange to an Interval in the given TimeZone.
*
* The result is an Interval from 00:00 on the start date to 00:00 on the end date + one day
* (the end Instant of Interval being exclusive).
*/

Copy link
Member

Choose a reason for hiding this comment

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

Also, should we add a warning relative to this?

As to what happens if 00:00 falls within a DST transition (I'm not even sure if this is possible in any timezone).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants