23 lines
982 B
Cheetah
23 lines
982 B
Cheetah
![]() |
{{- $start_time := collections.Index . "start_time" -}}
|
||
|
{{- $long_format := collections.Index . "long_format" -}}
|
||
|
|
||
|
{{- $start_time_ms := math.Floor (math.Mul $start_time 1000) -}}
|
||
|
{{- $time_str := "" -}}
|
||
|
{{- $hour_cnt := math.Div $start_time_ms 3600000 | math.Floor | cast.ToInt -}}
|
||
|
{{- $rem := math.Mod $start_time_ms 3600000 -}}
|
||
|
{{- if or $long_format (compare.Gt $hour_cnt 0) -}}
|
||
|
{{- $time_str = printf "%02d:" $hour_cnt -}}
|
||
|
{{- end -}}
|
||
|
{{- $min_cnt := math.Div $rem 60000 | math.Floor | cast.ToInt -}}
|
||
|
{{- $rem = math.Mod $rem 60000 -}}
|
||
|
{{- if or $long_format $time_str (compare.Gt $min_cnt 0) -}}
|
||
|
{{- $time_str = printf "%s%02d:" $time_str $min_cnt -}}
|
||
|
{{- end -}}
|
||
|
{{- $sec_cnt := math.Div $rem 1000 | math.Floor | cast.ToInt -}}
|
||
|
{{- $time_str = printf "%s%02d" $time_str $sec_cnt -}}
|
||
|
{{- $ms_cnt := math.Mod $rem 1000 -}}
|
||
|
{{- if or $long_format (compare.Gt $ms_cnt 0) -}}
|
||
|
{{- $time_str = printf "%s.%03d" $time_str $ms_cnt -}}
|
||
|
{{- end -}}
|
||
|
{{- return $time_str -}}
|