{"record":{"id":"a280921765345288","repo":"gohugoio/hugo","slug":"invalid-arguments-supplied-to-time","errorCode":null,"errorMessage":"invalid arguments supplied to `time`","messagePattern":"invalid arguments supplied to `time`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/time/init.go","lineNumber":55,"sourceCode":"\t\t\tContext: func(cctx context.Context, args ...any) (any, error) {\n\t\t\t\t// Handle overlapping \"time\" namespace and func.\n\t\t\t\t//\n\t\t\t\t// If no args are passed to `time`, assume namespace usage and\n\t\t\t\t// return namespace context.\n\t\t\t\t//\n\t\t\t\t// If args are passed, call AsTime().\n\n\t\t\t\tswitch len(args) {\n\t\t\t\tcase 0:\n\t\t\t\t\treturn ctx, nil\n\t\t\t\tcase 1:\n\t\t\t\t\treturn ctx.AsTime(args[0])\n\t\t\t\tcase 2:\n\t\t\t\t\treturn ctx.AsTime(args[0], args[1])\n\n\t\t\t\t// 3 or more arguments. Currently not supported.\n\t\t\t\tdefault:\n\t\t\t\t\treturn nil, errors.New(\"invalid arguments supplied to `time`\")\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\n\t\tns.AddMethodMapping(ctx.AsTime,\n\t\t\tnil,\n\t\t\t[][2]string{\n\t\t\t\t{`{{ (time \"2015-01-21\").Year }}`, `2015`},\n\t\t\t},\n\t\t)\n\n\t\tns.AddMethodMapping(ctx.Duration,\n\t\t\t[]string{\"duration\"},\n\t\t\t[][2]string{\n\t\t\t\t{`{{ mul 60 60 | duration \"second\" }}`, `1h0m0s`},\n\t\t\t},\n\t\t)\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/time/init.go#L37-L73","documentation":"Thrown by the `time` template namespace/func dispatcher when three or more arguments are passed (tpl/time/init.go:54-55). The time func accepts zero (namespace), one (value), or two (value + layout) arguments only; more than two is unsupported.","triggerScenarios":"Calling {{ time \"2015-01-21\" \"2006-01-02\" \"extra\" }} or {{ time .Date .Layout .TZ }} with three or more args.","commonSituations":"Trying to pass a timezone as a third argument (not supported); copy-pasting examples with extra layout fields; misunderstanding the namespace-vs-func overload.","solutions":["Reduce to at most two arguments: {{ time \"2015-01-21\" }} or {{ time .Date \"2006-01-02\" }}.","For timezone handling, use the result's .In method or the langs/location config rather than a third arg."],"exampleFix":"// before\n{{ time .Date .Layout .TZ }}\n// after\n{{ time .Date .Layout }}","handlingStrategy":"validation","validationCode":"{{ time .Date }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["time accepts at most value + layout (two args).","Handle timezones via the result's .In method, not a third arg."],"tags":["template-function","time","arity","argument"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}