Skip to content

Commit

Permalink
tp11 solution
Browse files Browse the repository at this point in the history
  • Loading branch information
ctruchi committed Feb 26, 2025
1 parent dcd6ab7 commit 28bf7c5
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions tp11/src/main/kotlin/fmt/kotlin/fundamentals/Tp11.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,31 @@ import kotlin.time.Duration.Companion.days

class Tp11 {

fun whichDayIsInTwoDays(clock: Clock): DayOfWeek = TODO()
fun whichDayIsInTwoDays(clock: Clock) = (clock.now() + 2.days)
.toLocalDateTime(TimeZone.of("Europe/Paris"))
.dayOfWeek

fun parseInstant(s: String): LocalDateTime = TODO()
fun parseInstant(s: String) =
LocalDateTime.Format {
dayOfMonth()
alternativeParsing({
char('/')
monthNumber()
char('/')
}) {
char(' ')
monthName(frenchMonthNames)
char(' ')
}
yearTwoDigits(1900)
chars(" à ")
hour()
char('h')
minute()
}.parse(s)

fun daysBetween(instant1: Instant, instant2: Instant): Long = TODO()
fun daysBetween(instant1: Instant, instant2: Instant) =
(instant2 - instant1).inWholeDays

companion object {
private val frenchMonthNames = MonthNames(
Expand Down

0 comments on commit 28bf7c5

Please sign in to comment.