-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
115 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
...in/kotlin/com/egoriku/grodnoroads/settings/changelog/domain/util/DateFormatter.android.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
...commonMain/kotlin/com/egoriku/grodnoroads/settings/changelog/domain/util/DateFormatter.kt
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
kmp/features/settings/changelog/src/commonTest/kotlin/DateFormatterTest.kt
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
...osMain/kotlin/com/egoriku/grodnoroads/settings/changelog/domain/util/DateFormatter.ios.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...tter/src/commonMain/kotlin/com/egoriku/grodnoroads/shared/formatter/ChangelogFormatter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.egoriku.grodnoroads.shared.formatter | ||
|
||
import kotlinx.datetime.Instant | ||
import kotlinx.datetime.LocalDateTime | ||
import kotlinx.datetime.TimeZone | ||
import kotlinx.datetime.format | ||
import kotlinx.datetime.format.MonthNames | ||
import kotlinx.datetime.format.Padding | ||
import kotlinx.datetime.format.char | ||
import kotlinx.datetime.toLocalDateTime | ||
|
||
object ChangelogFormatter { | ||
|
||
private val defaultTimeZone = TimeZone.of("Europe/Minsk") | ||
private val dayMonthYearFormatter = LocalDateTime.Format { | ||
dayOfMonth(padding = Padding.NONE) | ||
char(' ') | ||
monthName(MonthNames.ENGLISH_FULL) | ||
char(',') | ||
char(' ') | ||
year() | ||
} | ||
|
||
fun format(timestamp: Long): String = | ||
Instant.fromEpochMilliseconds(timestamp) | ||
.toLocalDateTime(defaultTimeZone) | ||
.format(dayMonthYearFormatter) | ||
} |
28 changes: 28 additions & 0 deletions
28
.../src/commonTest/kotlin/com/egoriku/grodnoroads/shared/formatter/ChangelogFormatterTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.egoriku.grodnoroads.shared.formatter | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlinx.datetime.LocalDate | ||
import kotlinx.datetime.TimeZone | ||
import kotlinx.datetime.atStartOfDayIn | ||
|
||
class ChangelogFormatterTest { | ||
|
||
@Test | ||
fun formatterTest() { | ||
assertEquals( | ||
expected = "10 March, 2023", | ||
actual = ChangelogFormatter.format(1678395600000) | ||
) | ||
assertEquals( | ||
expected = "5 January, 2023", | ||
actual = ChangelogFormatter.format( | ||
timestamp = LocalDate( | ||
year = 2023, | ||
monthNumber = 1, | ||
dayOfMonth = 5 | ||
).atStartOfDayIn(TimeZone.UTC).toEpochMilliseconds() | ||
) | ||
) | ||
} | ||
} |