Skip to content

Commit

Permalink
Add local date at Start of Day & End of Day (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
seljabali committed Feb 7, 2024
1 parent 4dc8d3c commit 856b2a4
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package localdate.extensions

import java.time.DayOfWeek
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime

fun LocalDate.getLast(dayOfWeek: DayOfWeek, countingInThisDay: Boolean = false): LocalDate {
if (countingInThisDay && this.dayOfWeek == dayOfWeek) {
Expand Down Expand Up @@ -29,4 +31,8 @@ fun LocalDate.getNext(dayOfWeek: DayOfWeek, countingInThisDay: Boolean = false):
nextLocalDate = nextLocalDate.plusDays(1)
}
return nextLocalDate
}
}

fun LocalDate.startOfDay(): LocalDateTime = LocalDateTime.of(this, LocalTime.MIN)

fun LocalDate.atEndOfDay(): LocalDateTime = LocalDateTime.of(this, LocalTime.MAX)

0 comments on commit 856b2a4

Please sign in to comment.