Skip to content

Removing Instant deprecated code #256

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

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.toquete.boxbox.core.common.util

import kotlinx.datetime.Instant
import kotlinx.datetime.toInstant

fun dateAndTimeToInstant(date: String?, time: String?): Instant? {
return when {
date == null -> null
time == null -> "${date}T00:00:00Z".toInstant()
else -> "${date}T$time".toInstant()
time == null -> Instant.parse("${date}T00:00:00Z")
else -> Instant.parse("${date}T$time")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.toquete.boxbox.core.database.model.RaceEntity
import com.toquete.boxbox.core.model.Race
import com.toquete.boxbox.core.network.model.PracticeResponse
import com.toquete.boxbox.core.network.model.RaceResponse
import kotlinx.datetime.toInstant
import kotlinx.datetime.Instant

val racesResponse = listOf(
RaceResponse(
Expand Down Expand Up @@ -85,11 +85,11 @@ val races = listOf(
url = "https://en.wikipedia.org/wiki/2023_Bahrain_Grand_Prix",
name = "Bahrain Grand Prix",
circuit = circuits.first(),
dateTime = "2023-03-05T15:00:00Z".toInstant(),
firstPracticeDateTime = "2023-03-03T11:30:00Z".toInstant(),
secondPracticeDateTime = "2023-03-03T15:00:00Z".toInstant(),
thirdPracticeDateTime = "2023-03-04T11:30:00Z".toInstant(),
qualifyingDateTime = "2023-03-04T15:00:00Z".toInstant(),
dateTime = Instant.parse("2023-03-05T15:00:00Z"),
firstPracticeDateTime = Instant.parse("2023-03-03T11:30:00Z"),
secondPracticeDateTime = Instant.parse("2023-03-03T15:00:00Z"),
thirdPracticeDateTime = Instant.parse("2023-03-04T11:30:00Z"),
qualifyingDateTime = Instant.parse("2023-03-04T15:00:00Z"),
sprintDateTime = null
),
Race(
Expand All @@ -98,11 +98,11 @@ val races = listOf(
url = "https://en.wikipedia.org/wiki/2023_United_States_Grand_Prix",
name = "United States Grand Prix",
circuit = circuits.last(),
dateTime = "2023-10-22T19:00:00Z".toInstant(),
firstPracticeDateTime = "2023-10-20T17:30:00Z".toInstant(),
secondPracticeDateTime = "2023-10-21T18:00:00Z".toInstant(),
dateTime = Instant.parse("2023-10-22T19:00:00Z"),
firstPracticeDateTime = Instant.parse("2023-10-20T17:30:00Z"),
secondPracticeDateTime = Instant.parse("2023-10-21T18:00:00Z"),
thirdPracticeDateTime = null,
qualifyingDateTime = "2023-10-20T21:00:00Z".toInstant(),
sprintDateTime = "2023-10-21T22:00:00Z".toInstant()
qualifyingDateTime = Instant.parse("2023-10-20T21:00:00Z"),
sprintDateTime = Instant.parse("2023-10-21T22:00:00Z")
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.toquete.boxbox.core.network.model.DriverResponse
import com.toquete.boxbox.core.network.model.RaceResponse
import com.toquete.boxbox.core.network.model.RaceResultResponse
import com.toquete.boxbox.core.network.model.TimeResponse
import kotlinx.datetime.toInstant
import kotlinx.datetime.Instant

val sprintRacesResponse = listOf(
RaceResponse(
Expand Down Expand Up @@ -104,11 +104,11 @@ val sprintRaces = listOf(
url = "https://en.wikipedia.org/wiki/2023_Bahrain_Grand_Prix",
name = "Bahrain Grand Prix",
circuit = circuits.first(),
dateTime = "2023-03-05T15:00:00Z".toInstant(),
firstPracticeDateTime = "2023-03-03T11:30:00Z".toInstant(),
secondPracticeDateTime = "2023-03-03T15:00:00Z".toInstant(),
thirdPracticeDateTime = "2023-03-04T11:30:00Z".toInstant(),
qualifyingDateTime = "2023-03-04T15:00:00Z".toInstant(),
dateTime = Instant.parse("2023-03-05T15:00:00Z"),
firstPracticeDateTime = Instant.parse("2023-03-03T11:30:00Z"),
secondPracticeDateTime = Instant.parse("2023-03-03T15:00:00Z"),
thirdPracticeDateTime = Instant.parse("2023-03-04T11:30:00Z"),
qualifyingDateTime = Instant.parse("2023-03-04T15:00:00Z"),
sprintDateTime = null
),
Race(
Expand All @@ -117,11 +117,11 @@ val sprintRaces = listOf(
url = "https://en.wikipedia.org/wiki/2023_United_States_Grand_Prix",
name = "United States Grand Prix",
circuit = circuits.last(),
dateTime = "2023-10-22T19:00:00Z".toInstant(),
firstPracticeDateTime = "2023-10-20T17:30:00Z".toInstant(),
secondPracticeDateTime = "2023-10-21T18:00:00Z".toInstant(),
dateTime = Instant.parse("2023-10-22T19:00:00Z"),
firstPracticeDateTime = Instant.parse("2023-10-20T17:30:00Z"),
secondPracticeDateTime = Instant.parse("2023-10-21T18:00:00Z"),
thirdPracticeDateTime = null,
qualifyingDateTime = "2023-10-20T21:00:00Z".toInstant(),
sprintDateTime = "2023-10-21T22:00:00Z".toInstant()
qualifyingDateTime = Instant.parse("2023-10-20T21:00:00Z"),
sprintDateTime = Instant.parse("2023-10-21T22:00:00Z")
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import com.toquete.boxbox.core.ui.annotation.UiModePreviews
import com.toquete.boxbox.core.ui.custom.BoxBoxAsyncImage
import com.toquete.boxbox.core.ui.theme.BoxBoxTheme
import com.toquete.boxbox.core.ui.theme.FormulaOne
import kotlinx.datetime.toInstant
import kotlinx.datetime.Instant
import com.toquete.boxbox.core.ui.R as uiR

@Composable
Expand Down Expand Up @@ -172,11 +172,11 @@ internal fun RaceItemPreview() {
flagUrl = null,
imageUrl = null
),
dateTime = "2023-03-05T15:00:00Z".toInstant(),
firstPracticeDateTime = "2023-03-03T11:30:00Z".toInstant(),
secondPracticeDateTime = "2023-03-03T15:00:00Z".toInstant(),
thirdPracticeDateTime = "2023-03-04T11:30:00Z".toInstant(),
qualifyingDateTime = "2023-03-04T15:00:00Z".toInstant(),
dateTime = Instant.parse("2023-03-05T15:00:00Z"),
firstPracticeDateTime = Instant.parse("2023-03-03T11:30:00Z"),
secondPracticeDateTime = Instant.parse("2023-03-03T15:00:00Z"),
thirdPracticeDateTime = Instant.parse("2023-03-04T11:30:00Z"),
qualifyingDateTime = Instant.parse("2023-03-04T15:00:00Z"),
sprintDateTime = null
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import com.toquete.boxbox.core.ui.annotation.UiModePreviews
import com.toquete.boxbox.core.ui.theme.BoxBoxTheme
import com.toquete.boxbox.feature.races.model.RacesTab
import kotlinx.coroutines.launch
import kotlinx.datetime.toInstant
import kotlinx.datetime.Instant

@Composable
internal fun RacesRoute(
Expand Down Expand Up @@ -142,11 +142,11 @@ internal fun RacesContentPreview() {
flagUrl = null,
imageUrl = null
),
dateTime = "2023-03-05T15:00:00Z".toInstant(),
firstPracticeDateTime = "2023-03-03T11:30:00Z".toInstant(),
secondPracticeDateTime = "2023-03-03T15:00:00Z".toInstant(),
thirdPracticeDateTime = "2023-03-04T11:30:00Z".toInstant(),
qualifyingDateTime = "2023-03-04T15:00:00Z".toInstant(),
dateTime = Instant.parse("2023-03-05T15:00:00Z"),
firstPracticeDateTime = Instant.parse("2023-03-03T11:30:00Z"),
secondPracticeDateTime = Instant.parse("2023-03-03T15:00:00Z"),
thirdPracticeDateTime = Instant.parse("2023-03-04T11:30:00Z"),
qualifyingDateTime = Instant.parse("2023-03-04T15:00:00Z"),
sprintDateTime = null
)
)
Expand Down