in src/formatting.ts [44:90]
export function findDateFormat(value: Date, format: string, cultureName: string): DateFormat {
switch (format) {
case "m":
// Month + day
format = "M";
break;
case "O":
case "o":
// Roundtrip
format = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'0000'";
break;
case "R":
case "r":
// RFC1123 pattern - - time must be converted to UTC before formatting
value = new Date(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate(), value.getUTCHours(), value.getUTCMinutes(), value.getUTCSeconds(), value.getUTCMilliseconds());
format = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'";
break;
case "s":
// Sortable - should use invariant culture
format = "S";
break;
case "u":
// Universal sortable - should convert to UTC before applying the "yyyy'-'MM'-'dd HH':'mm':'ss'Z' format.
value = new Date(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate(), value.getUTCHours(), value.getUTCMinutes(), value.getUTCSeconds(), value.getUTCMilliseconds());
format = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'";
break;
case "U":
// Universal full - the pattern is same as F but the time must be converted to UTC before formatting
value = new Date(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate(), value.getUTCHours(), value.getUTCMinutes(), value.getUTCSeconds(), value.getUTCMilliseconds());
format = "F";
break;
case "y":
case "Y":
// Year and month
switch (cultureName) {
case "default":
case "en":
case "en-US":
format = "MMMM, yyyy"; // Fix the default year-month pattern for english
break;
default:
format = "Y"; // For other cultures - use the localized pattern
}
break;
}
return { value: value, format: format };
}