Closed maniac103 closed 1 year ago
Do you think you can contribute this yourself?
As an example, you can find the code for isBetweenTimes
here:
https://github.com/openhab/openhab-js/blob/dc14c50fccd005d29025651c82b3fee6348b10d5/time.js#L312
I think so, yes. I'll give it a shot; just wanted to check your opinion first.
👍
I would add the following:
Also have a look at the CONTRIBUTING.md for code style and type defs.
Why not stay with isBefore and isAfter? That way
We already have these:
isBetweenTimes
: compares time portions and accounts midnightisBetweenDates
: compares date portionsisBetweenDateTimes
: compares both the time & dateSee https://github.com/openhab/openhab-js#isbetweentimesstart-end.
Therefore I‘d like to have the before and after checks to have these three different „modes“ as well to have a consistent API.
there's no potential time zone confusion ( e.g. would "2023-05-01 00:00 -05:00".isBeforeDate("2023-05-01 00:00 +01:00") return true or false?)
I guess .toLocalDate
returns a LocalDate that takes the zone into account. Depending on your location this will either be true or false.
The time zone confusion is no argument against providing these three methods.
Okay, fair enough. I'll implement that.
The time library provides a very nice
ZonedDateTime.isBetweenTimes
method. If I don't need a 'between' check, but only an after/before check, I need to fall back toLocalTime
, creating inconsistent code:It would be great if the library could provide additions for isBefore/isAfter for
ZonedDateTime
.