Template:Human readable duration/testcases

Invalid values

edit

No parameters

edit
  • {{Human readable duration}}Human readable duration error: First argument must be a positive number (help)
  • {{Human readable duration/sandbox}}Human readable duration error: First argument must be a positive number (help)


Missing second parameter

edit
  • {{Human readable duration|5}}Human readable duration error: Second argument must be a valid time unit (help)
  • {{Human readable duration/sandbox|5}}Human readable duration error: Second argument must be a valid time unit (help)


Bad first parameter

edit
  • {{Human readable duration||seconds}}Human readable duration error: First argument must be a positive number (help)
  • {{Human readable duration/sandbox||seconds}}Human readable duration error: First argument must be a positive number (help)
  • {{Human readable duration|yes|seconds}}Human readable duration error: First argument must be a positive number (help)
  • {{Human readable duration/sandbox|yes|seconds}}Human readable duration error: First argument must be a positive number (help)
  • {{Human readable duration|-5|seconds}}Human readable duration error: First argument must be a positive number (help)
  • {{Human readable duration/sandbox|-5|seconds}}Human readable duration error: First argument must be a positive number (help)


Bad second parameter

edit
  • {{Human readable duration|5|}}Human readable duration error: Second argument must be a valid time unit (help)
  • {{Human readable duration/sandbox|5|}}Human readable duration error: Second argument must be a valid time unit (help)
  • {{Human readable duration|5|yes}}Human readable duration error: Second argument must be a valid time unit (help)
  • {{Human readable duration/sandbox|5|yes}}Human readable duration error: Second argument must be a valid time unit (help)


Mixed case in second parameter

edit
  • {{Human readable duration|2|sEcOnDs}} → 2 seconds
  • {{Human readable duration/sandbox|2|sEcOnDs}} → 2 seconds
  • {{Human readable duration|2|Minutes}} → 2 minutes
  • {{Human readable duration/sandbox|2|Minutes}} → 2 minutes
  • {{Human readable duration|2|HOURS}} → 2 hours
  • {{Human readable duration/sandbox|2|HOURS}} → 2 hours
  • {{Human readable duration|2|dayS}} → 2 days
  • {{Human readable duration/sandbox|2|dayS}} → 2 days
  • {{Human readable duration|2|months}} → 2 months
  • {{Human readable duration/sandbox|2|months}} → 2 months
  • {{Human readable duration|2|YEArs}} → 2 years
  • {{Human readable duration/sandbox|2|YEArs}} → 2 years


Decimals in first parameter

edit
  • {{Human readable duration|2.33333333|seconds}} → 2.5 seconds
  • {{Human readable duration/sandbox|2.33333333|seconds}} → 2.5 seconds
  • {{Human readable duration|2.0|minutes}} → 2 minutes
  • {{Human readable duration/sandbox|2.0|minutes}} → 2 minutes
  • {{Human readable duration|2.99999999|hours}} → 3 hours
  • {{Human readable duration/sandbox|2.99999999|hours}} → 3 hours
  • {{Human readable duration|2.75|days}} → 66 hours
  • {{Human readable duration/sandbox|2.75|days}} → 66 hours
  • {{Human readable duration|2.00000001|months}} → 2 months
  • {{Human readable duration/sandbox|2.00000001|months}} → 2 months
  • {{Human readable duration|2.5|years}} → 2.5 years
  • {{Human readable duration/sandbox|2.5|years}} → 2.5 years


Zero

edit
  • {{Human readable duration|0|seconds}} → 0 seconds
  • {{Human readable duration/sandbox|0|seconds}} → 0 seconds
  • {{Human readable duration|0|minutes}} → 0 seconds
  • {{Human readable duration/sandbox|0|minutes}} → 0 seconds
  • {{Human readable duration|0|hours}} → 0 seconds
  • {{Human readable duration/sandbox|0|hours}} → 0 seconds
  • {{Human readable duration|0|days}} → 0 seconds
  • {{Human readable duration/sandbox|0|days}} → 0 seconds
  • {{Human readable duration|0|months}} → 0 seconds
  • {{Human readable duration/sandbox|0|months}} → 0 seconds
  • {{Human readable duration|0|years}} → 0 seconds
  • {{Human readable duration/sandbox|0|years}} → 0 seconds


Nearly zero

edit
  • {{Human readable duration|0.1|seconds}} → 0 seconds
  • {{Human readable duration/sandbox|0.1|seconds}} → 0 seconds
  • {{Human readable duration|0.1|minutes}} → 6 seconds
  • {{Human readable duration/sandbox|0.1|minutes}} → 6 seconds
  • {{Human readable duration|0.1|hours}} → 6 minutes
  • {{Human readable duration/sandbox|0.1|hours}} → 6 minutes
  • {{Human readable duration|0.1|days}} → 2.5 hours
  • {{Human readable duration/sandbox|0.1|days}} → 2.5 hours
  • {{Human readable duration|0.1|months}} → 3 days
  • {{Human readable duration/sandbox|0.1|months}} → 3 days
  • {{Human readable duration|0.1|years}} → 36.5 days
  • {{Human readable duration/sandbox|0.1|years}} → 36.5 days


Special exceptions

edit
  • {{Human readable duration|24|hours}} → 1 day
  • {{Human readable duration/sandbox|24|hours}} → 1 day
  • {{Human readable duration|48|hours}} → 2 days
  • {{Human readable duration/sandbox|48|hours}} → 2 days


Good values already (output = input)

edit
  • {{Human readable duration|1|seconds}} → 1 second
  • {{Human readable duration/sandbox|1|seconds}} → 1 second
  • {{Human readable duration|1|minutes}} → 1 minute
  • {{Human readable duration/sandbox|1|minutes}} → 1 minute
  • {{Human readable duration|1|hours}} → 1 hour
  • {{Human readable duration/sandbox|1|hours}} → 1 hour
  • {{Human readable duration|1|days}} → 1 day
  • {{Human readable duration/sandbox|1|days}} → 1 day
  • {{Human readable duration|6|months}} → 6 months
  • {{Human readable duration/sandbox|6|months}} → 6 months
  • {{Human readable duration|2|years}} → 2 years
  • {{Human readable duration/sandbox|2|years}} → 2 years


Boundary conditions

edit
  • {{Human readable duration|59.74|seconds}} → 59.5 seconds
  • {{Human readable duration/sandbox|59.74|seconds}} → 59.5 seconds
  • {{Human readable duration|59.75|seconds}} → 1 minute
  • {{Human readable duration/sandbox|59.75|seconds}} → 1 minute


  • {{Human readable duration|59.74|minutes}} → 59.5 minutes
  • {{Human readable duration/sandbox|59.74|minutes}} → 59.5 minutes
  • {{Human readable duration|59.75|minutes}} → 1 hour
  • {{Human readable duration/sandbox|59.75|minutes}} → 1 hour


  • {{Human readable duration|71.74|hours}} → 71.5 hours
  • {{Human readable duration/sandbox|71.74|hours}} → 71.5 hours
  • {{Human readable duration|71.75|hours}} → 3 days
  • {{Human readable duration/sandbox|71.75|hours}} → 3 days


  • {{Human readable duration|50.24|days}} → 50 days
  • {{Human readable duration/sandbox|50.24|days}} → 50 days
  • {{Human readable duration|50.25|days}} → 2 months
  • {{Human readable duration/sandbox|50.25|days}} → 2 months


  • {{Human readable duration|18.49|months}} → 18 months
  • {{Human readable duration/sandbox|18.49|months}} → 18 months
  • {{Human readable duration|18.50|months}} → 1.5 years
  • {{Human readable duration/sandbox|18.50|months}} → 1.5 years


Random typical values

edit
  • {{Human readable duration|2880|hours}} → 4 months
  • {{Human readable duration/sandbox|2880|hours}} → 4 months
  • {{Human readable duration|100|days}} → 3 months
  • {{Human readable duration/sandbox|100|days}} → 3 months
  • {{Human readable duration|10000|months}} → 833.5 years
  • {{Human readable duration/sandbox|10000|months}} → 833.5 years
  • {{Human readable duration|30|seconds}} → 30 seconds
  • {{Human readable duration/sandbox|30|seconds}} → 30 seconds
  • {{Human readable duration|100000|seconds}} → 28 hours
  • {{Human readable duration/sandbox|100000|seconds}} → 28 hours

Additional in situ tests at Template:Talk header

edit

An additional set of test cases can be found at Template:Talk header/testcases4#Testing human readable time units. These tests involve observing the results of template {{Talk header}} in actual use.