add klock dependency and fix exposed lib

This commit is contained in:
InsanusMokrassar 2020-01-31 18:05:39 +06:00
parent f3ad03c51f
commit dfeb628fd1
2 changed files with 8 additions and 3 deletions

View File

@ -32,6 +32,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
api "com.insanusmokrassar:postssystem.core:$core_version"
api "org.jetbrains.exposed:exposed-core:$exposed_version"
api "com.soywiz.korlibs.klock:klock:$klockVersion"
testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$test_junit_version"

View File

@ -5,7 +5,7 @@ import com.insanusmokrassar.postssystem.core.post.*
import com.insanusmokrassar.postssystem.core.post.api.PostsAPI
import com.insanusmokrassar.postssystem.core.utils.generatePostId
import com.insanusmokrassar.postssystem.core.utils.pagination.*
import com.soywiz.klock.DateTime
import com.soywiz.klock.*
import kotlinx.coroutines.channels.BroadcastChannel
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
@ -58,13 +58,17 @@ private class PostsAPIContentRelations(
}
}
private val dateTimeFormat = DateFormat("EEE, dd MMM yyyy HH:mm:ss z")
private class PostsAPIDatabaseTable(
private val database: Database
) : PostsAPI, Table() {
private val contentsTable = PostsAPIContentRelations(database)
private val idColumn = text("postId")
private val creationDateColumn = datetime("creationDate").default(org.joda.time.DateTime.now())
private val creationDateColumn = text("creationDate").default(
DateTime.now().toString(dateTimeFormat)
)
private val postCreatedBroadcastChannel = BroadcastChannel<RegisteredPost>(Channel.BUFFERED)
@ -88,7 +92,7 @@ private class PostsAPIDatabaseTable(
SimpleRegisteredPost(
id,
contentsTable.getPostContents(id),
DateTime(get(creationDateColumn).millis)
dateTimeFormat.parse(get(creationDateColumn)).local
)
}