sadium/layouts/shortcodes/age.html
Артём c259a51818
All checks were successful
/ site (push) Successful in 1s
Счётчик годиков
2024-06-15 20:59:38 +03:00

17 lines
411 B
HTML

{{ $birth := "2000-10-28" | time }}
{{ $today := now }}
{{ $age := sub $today.Year $birth.Year }}
{{ $monthDiff := sub $today.Month $birth.Month }}
{{ $dayDiff := sub $today.Day $birth.Day }}
{{ if (gt $monthDiff 0) }}
{{ $age }}
{{ else if (lt $monthDiff 0) }}
{{ sub $age 1 }}
{{ else }}
{{ if (ge $dayDiff 0) }}
{{ $age }}
{{ else }}
{{ sub $age 1 }}
{{ end }}
{{ end }}