Template:Human readable duration
| This template is used on approximately 35,000 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
| This template uses Lua: |
This template takes a duration as input, and converts it to a duration with units such that the value will be relatively small for readability. For example, 3600 seconds will be converted to 1 hour. This conversion will result in loss of precision in nearly all cases, and is meant only for situations where the exact value is unimportant: for example, 123456789 seconds is approx. 3,915 years but will be converted to 4 years.
Usage
{{human readable duration|duration|unit}}
Parameters
This template requires two positional parameters:
|1= The amount of time to convert from, expressed in the unit given.
|2= The unit which the duration is expressed in. Must be one of second, minute, hour, day, month, or year, optionally pluralized.
Examples
{{human readable duration|10|seconds}}→ 10 seconds{{human readable duration|0.0027|hours}}→ 9.5 seconds{{human readable duration|1000|minutes}}→ 16.5 hours{{human readable duration|24|hours}}→ 1 day{{human readable duration|50|hours}}→ 50 hours{{human readable duration|100|hours}}→ 4 days{{human readable duration|66|months}}→ 5.5 years
Function
For the purposes of this template "relatively small values" include up to 60 seconds, 60 minutes, 72 hours, 50 days, 18 months, and years rounded to half a year above that. So a value of 1000 minutes is presented as 16.5 hours because 1000 is "too large" a number to present in the unit given. In the next bigger unit (hours), however, 1000 minutes is expressed using a number less than 72, so that's what we end up with.
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.