duration
少于1分钟
将以下英文翻译为中文:
duration
https://gohugo.io/functions/duration/
Returns a time.Duration structure, using the given time unit and duration number.
语法
duration TIME_UNIT DURATION_NUMBER
time.Duration converts a given number into a time.Duration structure so you can access its fields. E.g. you can perform time operations on the returned time.Duration value:
{{ printf "There are %.0f seconds in one day." (duration "hour" 24).Seconds }}
<!-- Output: There are 86400 seconds in one day. -->
Make your code simpler to understand by using a chained pipeline:
{{ mul 7.75 60 | duration "minute" }} → 7h45m0s
{{ mul 120 60 | mul 1000 | duration "millisecond" }} → 2h0m0s
You have to specify a time unit for the number given to the function. Valid time units are:
| Duration | Valid time units |
|---|---|
| hours | hour, h |
| minutes | minute, m |
| seconds | second, s |
| milliseconds | millisecond, ms |
| microseconds | microsecond, us, µs |
| nanoseconds | nanosecond, ns |
最后修改 June 1, 2023: 新增一个配置参数:sidebar_menu_truncate = 500 用于解决菜单不全的问题 (27810f1)