Days difference

Report a typo

The function howManyDays(year1: Int, month1: Int, day1: Int, year2: Int, month2: Int, day2: Int) gets the data for two dates as parameters: (year1, month1, day1) and (year2, month2, day2), respectively. It returns an integer number that denotes the days difference between them.

If the second date occurs after the first, then the returned valued is a positive number, while if the first date occurs after the second, the number is negative.

Write the correct code for the howManyDays() function.

This task uses dependencies that may not be available in your local IDE. As a result, you may see compilation errors or unresolved references when running the code locally. This does not affect solution validation when you submit your solution to Hyperskill.

Sample Input 1:

2001 1 1
2000 1 1

Sample Output 1:

-366
Write a program in Kotlin
import kotlinx.datetime.*

fun howManyDays(year1: Int, month1: Int, day1: Int, year2: Int, month2: Int, day2: Int): Int {
// Write your code here

//
}

fun main() {
val (year1, month1, day1) = readln().split(" ").map { it.toInt() }
val (year2, month2, day2) = readln().split(" ").map { it.toInt() }

println(howManyDays(year1, month1, day1, year2, month2, day2))
}

Create a free account to access the full topic