Seconds to human readable format Given a positive integer input n seconds, output the time in human readable format.
The time will be considered from 00:00:00, 1st January, 1 A.D.
Leap years must be taken into account.
Assume that the gregorian calendar was followed since the beginning.
(Gregorian Calendar: Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400. For example, the years 1700, 1800, and 1900 were not leap years, but the years 1600 and 2000 were)
Output must be a string of the format:
x Millennia/Millennium, x Centuries/Century, x Decades/Decade, x Years/Year, x Months/Month, x Days/Day, x Hours/Hour, x Minutes/Minute and x Seconds/Second

The 0 values must not be shown.
Program must handle at least up to 999 Millennia(inclusive).
Plural/Singular must be kept in mind.
(For millennium, both millennia and millenniums are valid)
,,and and spaces must also be kept in mind.
Case may be anything.
Examples:
1:1 second
2:2 seconds
60:1 minute
62:1 minute and 2 seconds
3600:1 hour
3661:1 hour, 1 minute and 1 second
31536001:1 year and 1 second
317310301:1 decade, 20 days, 13 hours, 45 minutes and 1 second
3499454714:1 century, 1 decade, 10 months, 22 days, 22 hours, 45 minutes and 14 seconds
73019321114:2 millennia, 3 centuries, 1 decade, 3 years, 10 months, 22 days, 45 minutes and 14 seconds

Reference: date-difference to duration converter
This is code-golf so shortest code wins
Perl 6, 273 245 233 230 bytes

-28 bytes thanks to nwellnhof!



{S/rys/ries/}o{S:th(*)/\,/ and/}o{join ', ',map {$_~'s'x(.[0]&gt;1)},grep *[0],(|[R,](.[0].polymod(10 xx 3)),|.skip Z &lt;millennium century decade year month day hour minute second&gt;)}o{~DateTime.new($_-62135596800)~~m:g/\d+/Z-(^6 X&lt;3)}


Try it online!

I think there might be a trick or two I can use with EVAL to make this shorter. This solution takes into account leap seconds, so the last test case is a bit off. Both no longer applicable.

(Old) Explanation:

{                                      } # First code block
 DateTime.new($_-62135596800)  # Initialise a date time object with input amount of seconds
{  ...  }o    # Pass value to the next code block
 fmt(.year-1: "%04d").comb Z   # Zip each digit of the year with
                             &lt;millennium century decade year&gt;  # The appropriate word
 &lt;month day hour minute second&gt;.map:{  ...  }   # For each of these words
                                ".$^a".EVAL     # EVAL the method on the DateTime
                                           -(2&gt;$++)     # -1 if month or day
                                                   ,$a  # Followed by the word itself
  grep +*[0],  # From these, filter out the ones with value 0
  map {$_~'s'x(.[0]&gt;1)},    # Add plurals if greater than 1
  join ', ',                # Join with commas
 {  ...  }o         # Pass string to next code block
  S:th(*)           # Substitute the last instance of
         /\,/       # A comma
            / and/  # With ' and'
 {  ...  }o         # Pass to next code block
  S/rys/ries/       # Fix plural of century