From 8f9e25e81660d0627d2f7b340da3fb278193526c Mon Sep 17 00:00:00 2001 From: Alberto Spelta Date: Tue, 14 Jul 2026 13:42:37 +0200 Subject: [PATCH] Fix date format string to ignore per-user Windows regional overrides BaseDateTemplate.GetDefaultFormatString built the default DateTime formatString via new CultureInfo(isoCulture).DateTimeFormat.ShortDatePattern. That constructor defaults to useUserOverride: true, so on a machine where the Windows user has customized Control Panel > Region short-date format (even under a plain "en-US" locale), the emitted formatString silently changes with it - e.g. "yyyy-mm-dd" instead of the culture-defined "m/d/yyyy". This made generated templates non-reproducible across machines and was the actual cause of the StandardConfig_OfflineApply_MatchesSnapshot and CalendarStandardConfig_MatchesSnapshot golden-file failures. Pass useUserOverride: false so the format string depends only on the configured culture, not on the building machine's personal preferences. --- src/Dax.Template/Tables/Dates/BaseDateTemplate.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Dax.Template/Tables/Dates/BaseDateTemplate.cs b/src/Dax.Template/Tables/Dates/BaseDateTemplate.cs index f81e500..226c5f2 100644 --- a/src/Dax.Template/Tables/Dates/BaseDateTemplate.cs +++ b/src/Dax.Template/Tables/Dates/BaseDateTemplate.cs @@ -27,8 +27,11 @@ public BaseDateTemplate(T config, CustomTemplateDefinition template, Predicate Region), which + // `new CultureInfo(name)` otherwise applies by default even for a fully-qualified culture name. return (column.DataType == DataType.DateTime) - ? new CultureInfo(isoCulture).DateTimeFormat.ShortDatePattern.Replace('M', 'm') + ? new CultureInfo(isoCulture, useUserOverride: false).DateTimeFormat.ShortDatePattern.Replace('M', 'm') : null; }