Skip to content

Commit

Permalink
getDayInterval 增加 dayOffset 参数
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaojinzi123 committed Apr 16, 2024
1 parent b36e79a commit bf27fd4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib-ktx/src/main/java/com/xiaojinzi/support/ktx/Times.kt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ fun getYearByTimeStamp(
*/
fun getDayInterval(
timeStamp: Long,
dayOffset: Int = 0,
zone: TimeZone = TimeZone.getDefault(),
): Pair<Long, Long> {
val calendar = Calendar.getInstance(zone)
Expand All @@ -152,8 +153,9 @@ fun getDayInterval(
calendar[Calendar.SECOND] = 0
calendar[Calendar.MINUTE] = 0
calendar[Calendar.MILLISECOND] = 0
calendar.add(Calendar.DAY_OF_YEAR, dayOffset)
val start = calendar.timeInMillis
calendar.add(Calendar.DAY_OF_MONTH, 1)
calendar.add(Calendar.DAY_OF_YEAR, 1)
calendar.add(Calendar.MILLISECOND, -1)
val end = calendar.timeInMillis
return Pair(
Expand Down

0 comments on commit bf27fd4

Please sign in to comment.