First, you cannot parse either of these formats with the time.AsTime
method:
{{ time.AsTime "07/12/2022" }} --> error calling AsTime: unable to parse date
{{ time.AsTime "12/07/2022" }} --> error calling AsTime: unable to parse date
Second, although this is not what you asked for, the simplest approach is to use the (less ambiguous) ISO 8601 format:
{{ time.AsTime "2022-07-12" }}
Finally, if you want to use the dd/mm/yyyy
format in your shortcode parameters, you could do something like:
layouts/shortcodes/cvSingleElement.html
{{ $startDate := partial "cast-to-time.html" (.Get "startdate") }}
{{ $endDate := partial "cast-to-time.html" (.Get "enddate") }}
layouts/partials/cast-to-time.html
{{ $dateParts := split . "/" }}
{{ if lt (len $dateParts) 3 }}
{{ errorf "Cannot cast %s to time.Time value" . }}
{{ end }}
{{ return (time.AsTime (printf "%s-%s-%s" (index $dateParts 2) (index $dateParts 1) (index $dateParts 0))) }}