diff --git a/tp11/src/main/kotlin/fmt/kotlin/fundamentals/Tp11.kt b/tp11/src/main/kotlin/fmt/kotlin/fundamentals/Tp11.kt index a68f8bb..875e620 100644 --- a/tp11/src/main/kotlin/fmt/kotlin/fundamentals/Tp11.kt +++ b/tp11/src/main/kotlin/fmt/kotlin/fundamentals/Tp11.kt @@ -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(