| 158 | } |
| 159 | |
| 160 | FunctionCallResolution FormatDateFunctionCall::execute(const nlohmann::json& args) { |
| 161 | if (!args.contains("value") || !args.contains("format")) { |
| 162 | return FunctionCallResolution::createError("Missing required parameters"); |
| 163 | } |
| 164 | |
| 165 | if (!args["format"].is_string()) { |
| 166 | return FunctionCallResolution::createError("Format must be a string"); |
| 167 | } |
| 168 | |
| 169 | std::string format = args["format"].get<std::string>(); |
| 170 | std::time_t timestamp; |
| 171 | |
| 172 | if (args["value"].is_string()) { |
| 173 | // ISO 8601 string |
| 174 | std::string dateStr = args["value"].get<std::string>(); |
| 175 | timestamp = parseISO8601(dateStr); |
| 176 | |
| 177 | if (timestamp == -1) { |
| 178 | return FunctionCallResolution::createError("Invalid date string format"); |
| 179 | } |
| 180 | } else if (args["value"].is_number()) { |
| 181 | // Unix timestamp in milliseconds |
| 182 | int64_t ms = args["value"].get<int64_t>(); |
| 183 | timestamp = static_cast<std::time_t>(ms / 1000); |
| 184 | } else { |
| 185 | return FunctionCallResolution::createError("Value must be a string or number"); |
| 186 | } |
| 187 | |
| 188 | std::tm* tm = std::localtime(×tamp); |
| 189 | if (!tm) { |
| 190 | return FunctionCallResolution::createError("Failed to convert timestamp"); |
| 191 | } |
| 192 | |
| 193 | std::string result = formatWithTR35(*tm, format); |
| 194 | |
| 195 | return FunctionCallResolution::createSuccess(result); |
| 196 | } |
| 197 | |
| 198 | FunctionCallConfig FormatDateFunctionCall::getConfig() const { |
| 199 | FunctionCallConfig config; |
nothing calls this directly
no test coverage detected