in packages/jinja/src/utils.ts [63:92]
export function strftime(date: Date, format: string): string {
// Set locale to undefined to use the default locale
const monthFormatterLong = new Intl.DateTimeFormat(undefined, { month: "long" });
const monthFormatterShort = new Intl.DateTimeFormat(undefined, { month: "short" });
const pad2 = (n: number): string => (n < 10 ? "0" + n : n.toString());
return format.replace(/%[YmdbBHM%]/g, (token) => {
switch (token) {
case "%Y":
return date.getFullYear().toString();
case "%m":
return pad2(date.getMonth() + 1);
case "%d":
return pad2(date.getDate());
case "%b":
return monthFormatterShort.format(date);
case "%B":
return monthFormatterLong.format(date);
case "%H":
return pad2(date.getHours());
case "%M":
return pad2(date.getMinutes());
case "%%":
return "%";
default:
return token;
}
});
}