Skip to content

Commit

Permalink
Move date time formatter to core:base module
Browse files Browse the repository at this point in the history
  • Loading branch information
msasikanth committed Feb 15, 2024
1 parent 86d852e commit c8892b2
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 12 deletions.
2 changes: 2 additions & 0 deletions core/base/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ kotlin {
implementation(libs.kotlininject.runtime)
}

commonTest.dependencies { implementation(libs.kotlin.test) }

androidMain.dependencies { implementation(libs.androidx.annotation) }
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Sasikanth Miriyampalli
* Copyright 2024 Sasikanth Miriyampalli
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.sasikanth.rss.reader.core.network.parser
package dev.sasikanth.rss.reader.util

import java.time.Instant
import java.time.LocalDateTime
Expand Down Expand Up @@ -49,7 +49,7 @@ private val dateFormatters =
)

@Throws(DateTimeFormatException::class)
internal actual fun String?.dateStringToEpochMillis(clock: Clock): Long? {
actual fun String?.dateStringToEpochMillis(clock: Clock): Long? {
if (this.isNullOrBlank()) return null

val currentDate =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Sasikanth Miriyampalli
* Copyright 2024 Sasikanth Miriyampalli
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,10 +14,10 @@
* limitations under the License.
*/

package dev.sasikanth.rss.reader.core.network.parser
package dev.sasikanth.rss.reader.util

import kotlinx.datetime.Clock

internal expect fun String?.dateStringToEpochMillis(clock: Clock = Clock.System): Long?
expect fun String?.dateStringToEpochMillis(clock: Clock = Clock.System): Long?

data class DateTimeFormatException(val exception: Exception) : Exception()
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Sasikanth Miriyampalli
* Copyright 2024 Sasikanth Miriyampalli
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.sasikanth.rss.reader.core.network.parser
package dev.sasikanth.rss.reader.util

import kotlin.test.Test
import kotlin.test.assertEquals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.sasikanth.rss.reader.core.network.parser
package dev.sasikanth.rss.reader.util

import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Sasikanth Miriyampalli
* Copyright 2024 Sasikanth Miriyampalli
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.sasikanth.rss.reader.core.network.parser
package dev.sasikanth.rss.reader.util

import kotlinx.datetime.Clock
import kotlinx.datetime.TimeZone
Expand Down Expand Up @@ -69,7 +69,7 @@ private val dateFormatters =
)

@Throws(DateTimeFormatException::class)
internal actual fun String?.dateStringToEpochMillis(clock: Clock): Long? {
actual fun String?.dateStringToEpochMillis(clock: Clock): Long? {
if (this.isNullOrBlank()) return null

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.TAG_SUB
import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.TAG_SUMMARY
import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.TAG_TITLE
import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.TAG_UPDATED
import dev.sasikanth.rss.reader.util.dateStringToEpochMillis
import io.ktor.http.Url
import kotlinx.datetime.Clock
import org.kobjects.ktxml.api.EventType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.TAG_PUB
import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.TAG_RSS_CHANNEL
import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.TAG_RSS_ITEM
import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.TAG_TITLE
import dev.sasikanth.rss.reader.util.dateStringToEpochMillis
import io.ktor.http.Url
import kotlinx.datetime.Clock
import org.kobjects.ktxml.api.EventType
Expand Down

0 comments on commit c8892b2

Please sign in to comment.