Humanizr/Humanizer · error · ArgumentOutOfRangeException
Unknown clock-notation profile.
Error message
Unknown clock-notation profile.
What it means
This message is emitted into generated source code (TimeOnlyToClockNotationProfileCatalog.g.cs, gated by NET6_0_OR_GREATER) as the default case of the Resolve switch. At runtime, TimeOnlyToClockNotationProfileCatalog.Resolve(kind, culture) throws ArgumentOutOfRangeException when the kind string does not match any compiled clock-notation profile name. Only locales whose clock-notation feature was registered as generated appear in the switch.
Source
Thrown at src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/TimeOnlyToClockNotationProfileCatalogInput.cs:77
builder.AppendLine("namespace Humanizer;");
builder.AppendLine();
builder.AppendLine("static partial class TimeOnlyToClockNotationProfileCatalog");
builder.AppendLine("{");
builder.AppendLine(" public static ITimeOnlyToClockNotationConverter Resolve(string kind, CultureInfo culture)");
builder.AppendLine(" {");
builder.AppendLine(" switch (kind)");
builder.AppendLine(" {");
foreach (var profile in profiles.OrderBy(static profile => profile.ProfileName, StringComparer.Ordinal))
{
builder.Append(" case ");
builder.Append(QuoteLiteral(profile.ProfileName));
builder.Append(": return ");
builder.Append(GetCatalogPropertyName(profile.ProfileName));
builder.AppendLine(".WithCulture(culture);");
}
builder.AppendLine(" default: throw new ArgumentOutOfRangeException(nameof(kind), kind, \"Unknown clock-notation profile.\");");
builder.AppendLine(" }");
builder.AppendLine(" }");
builder.AppendLine();
foreach (var profile in profiles.OrderBy(static profile => profile.ProfileName, StringComparer.Ordinal))
{
AppendLazyCachedMember(
builder,
" ",
"static",
"PhraseClockNotationConverter",
GetCatalogPropertyName(profile.ProfileName),
TimeOnlyToClockNotationEngineContractFactory.Create(profile, contracts));
builder.AppendLine();
}
builder.AppendLine("}");
builder.AppendLine();View on GitHub (pinned to ffc2b77c0f)
Solutions
- Verify the target locale has a timeOnlyToClockNotation YAML block with a matching profile name.
- Ensure the clock-notation feature is registered with UsesGeneratedProfile: true in the locale YAML.
- Fall back to a known-supported locale (e.g. 'en') if the requested locale is unsupported.
- Confirm the project targets .NET 6.0 or later, since the catalog is compiled only under NET6_0_OR_GREATER.
Example fix
// before — 'xx' has no clock-notation profile
var clock = timeOnly.ToClockNotation(new CultureInfo("xx"));
// after — use a supported locale
var clock = timeOnly.ToClockNotation(new CultureInfo("en")); Defensive patterns
Strategy: validation
Validate before calling
// Before calling a clock-notation API with an arbitrary locale, verify support.
// Note: the catalog is compiled only under NET6_0_OR_GREATER.
var culture = new CultureInfo("en"); Try / catch
try
{
var converter = TimeOnlyToClockNotationProfileCatalog.Resolve(kind, culture);
}
catch (ArgumentOutOfRangeException)
{
converter = TimeOnlyToClockNotationProfileCatalog.Resolve("en", culture);
} Prevention
- Ensure the project targets .NET 6.0 or later — the clock-notation catalog is gated by NET6_0_OR_GREATER.
- Verify the target locale is shipped with a timeOnlyToClockNotation block.
- Use public APIs which fall back gracefully for unsupported locales.
When it happens
Trigger: Calling a clock-notation API (e.g. timeOnly.ToClockNotation()) with a culture whose clock-notation profile name is not compiled into the catalog. The feature may be missing for that locale or the profile name may not match.
Common situations: A consumer targets .NET 6+ and requests clock notation for an unsupported locale. This error is also gated to .NET 6+ — calling on older frameworks would not even compile the catalog.
Related errors
- Unknown number-to-words profile.
- Unknown ordinal date profile.
- Unknown ordinalizer profile.
- Unknown words-to-number profile.
- Specified argument was out of the range of valid values. (Pa
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/b80aa4301f7387f5.
Report an issue: GitHub.