{"record":{"id":"ad8729bf441d8583","repo":"mikefarah/yq","slug":"could-not-parse-datetime-of-v-using-layout-v","errorCode":null,"errorMessage":"could not parse datetime of [%v] using layout [%v]: %w","messagePattern":"could not parse datetime of \\[(.+?)\\] using layout \\[(.+?)\\]: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/yqlib/operator_datetime.go","lineNumber":117,"sourceCode":"\ttimezoneStr, err := getStringParameter(\"timezone\", d, context, expressionNode.RHS)\n\tlayout := context.GetDateTimeLayout()\n\n\tif err != nil {\n\t\treturn Context{}, err\n\t}\n\tvar results = list.New()\n\n\ttimezone, err := time.LoadLocation(timezoneStr)\n\tif err != nil {\n\t\treturn Context{}, fmt.Errorf(\"could not load tz [%v]: %w\", timezoneStr, err)\n\t}\n\n\tfor el := context.MatchingNodes.Front(); el != nil; el = el.Next() {\n\t\tcandidate := el.Value.(*CandidateNode)\n\n\t\tparsedTime, err := parseDateTime(layout, candidate.Value)\n\t\tif err != nil {\n\t\t\treturn Context{}, fmt.Errorf(\"could not parse datetime of [%v] using layout [%v]: %w\", candidate.GetNicePath(), layout, err)\n\t\t}\n\t\ttzTime := parsedTime.In(timezone)\n\n\t\tresults.PushBack(candidate.CreateReplacement(ScalarNode, candidate.Tag, tzTime.Format(layout)))\n\t}\n\n\treturn context.ChildContext(results), nil\n}\n\nfunc parseUnixTime(unixTime string) (time.Time, error) {\n\tseconds, err := strconv.ParseFloat(unixTime, 64)\n\n\tif err != nil {\n\t\treturn time.Now(), err\n\t}\n\n\treturn time.UnixMilli(int64(seconds * 1000)), nil\n}","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/mikefarah/yq/blob/8b5af0694bb82b41d4ae180fac9972029066f90a/pkg/yqlib/operator_datetime.go#L99-L135","documentation":"Inside the tz operator's per-node loop, parseDateTime could not interpret the node's scalar value using the currently active datetime layout (context.GetDateTimeLayout()). The value being converted and the layout are both printed; either the value is not a datetime at all or it uses a format that does not match the configured layout.","triggerScenarios":"Thrown at pkg/yqlib/operator_datetime.go:117 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the matching layout first, e.g. --datetime-format / with_datetime_format before tz","Ensure the node values really are datetimes (filter or select them first)","Fix malformed datetime strings in the source data"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8b5af0694bb82b41d4ae180fac9972029066f90a","analyzedAt":"2026-09-05T10:57:22.766Z","contentChangedAt":"2026-09-05T10:57:22.766Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}