[solved] Formatting a date via Scratch

I am trying to make an index in Algolia. Because my blog is “german” I need some kind of way to translate the date into some kind of “on monday, 12th of january 2012” thing that translates. I am using moment.js to translate dates.

Problem: I need a string in my json that is a valid date string that for instance moment.js understands. My json-index templte looks like this:

{{/* Generates a valid Algolia search index */}}
{{- $hits := slice -}}
{{- $section := $.Site.GetPage "section" .Section }}
{{- $validVars := $.Param "algolia.vars" | default slice -}}
{{- $validParams := $.Param "algolia.params" | default slice -}}
{{- range $i, $hit := .Site.AllPages -}}
  {{- $dot := . -}}
  {{- if or (and ($hit.IsDescendant $section) (and (not $hit.Draft) (not $hit.Params.private))) $section.IsHome -}}
{{/* Set the hit's objectID */}}
{{- .Scratch.SetInMap $hit.File.Path "objectID" $hit.UniqueID -}}
{{- .Scratch.SetInMap $hit.File.Path "date" $hit.Date.Format "January 2, 2006" -}}
{{- .Scratch.SetInMap $hit.File.Path "description" $hit.Description -}}
{{- .Scratch.SetInMap $hit.File.Path "publishdate" $hit.PublishDate -}}
{{- .Scratch.SetInMap $hit.File.Path "summary" $hit.Summary -}}
{{- .Scratch.SetInMap $hit.File.Path "title" $hit.Title -}}
{{- .Scratch.SetInMap $hit.File.Path "url" $hit.URL -}}   
{{- $.Scratch.SetInMap "hits" $hit.File.Path (.Scratch.Get $hit.File.Path) -}}
  {{- end -}}
{{- end -}}
{{- jsonify ($.Scratch.GetSortedMapValues "hits") -}}

the line

{{- .Scratch.SetInMap $hit.File.Path "date" $hit.Date.Format "January 2, 2006" -}}

throws errors, wrong number of args for SetInMap: want 3 got 4.

What would be the correct way to add an item “date” with the value of “January 2, 2006” (something moment.js can parse into a date object) for entries?

That was (in the end) easy:

{{- .Scratch.SetInMap $hit.File.Path "date" ($hit.Date.Format "January 2, 2006") -}}

Brackets around the date formatting and everyone is happy.