I have written if-else conditions for displaying date and time when it comes to 1 day, 1 hour, etc. I want to know whether there are any functions that would do that without adding these conditions. I am posting my code here
if(days.toInt() == 0 && hours.toInt() > 1)
{
result = "$hours hours"
}
else if(hours.toInt() == 0 && days.toInt() > 1)
{
result = "$days days"
}
else if(days.toInt() == 1 && hours.toInt() > 1)
{
result = "$days day $hours hours"
}
else if(hours.toInt() == 1 && days.toInt() > 1)
{
result = "$days days $hours hour"
}
else if(days.toInt() == 1 && hours.toInt() == 0)
{
result = "$days day"
}
else if(days.toInt() == 0 && hours.toInt() == 1)
{
result = "$hours hour"
}
else if(days.toInt() == 1 && hours.toInt() == 1)
{
result = "$days day $hours hour"
}
else if(hours.toInt() == 0 && days.toInt() ==0)
{
result = ""
}
else if(hours.toInt() > 1 && days.toInt() > 1)
{
result = "$days days $hours hours"
}
return result