feat: LiquidOptions.dateFormat to override default date format (#587)

doc: updates related to LiquidOptions.dateFormat
doc: revamped the date filter doc for easier reference
This commit is contained in:
prassie
2023-02-22 23:56:33 +08:00
committed by GitHub
parent d9cac4efca
commit 3fb66465c6
6 changed files with 71 additions and 59 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ export function date (this: FilterImpl, v: string | Date, format?: string, timez
let date: LiquidDate
v = toValue(v)
format = toValue(format)
if (isNil(format)) format = DEFAULT_FMT
if (isNil(format)) format = opts.dateFormat ?? DEFAULT_FMT
else format = stringify(format)
if (v === 'now' || v === 'today') {
date = new Date()
+2
View File
@@ -38,6 +38,8 @@ export interface LiquidOptions {
lenientIf?: boolean;
/** JavaScript timezone name or timezoneOffset for `date` filter, default to local time. That means if you're in Australia (UTC+10), it'll default to `-600` or `Australia/Lindeman` */
timezoneOffset?: number | string;
/** Default date format to use if the date filter doesn't include a format. Defaults to `%A, %B %-e, %Y at %-l:%M %P %z`. */
dateFormat?: string;
/** Strip blank characters (including ` `, `\t`, and `\r`) from the right of tags (`{% %}`) until `\n` (inclusive). Defaults to `false`. */
trimTagRight?: boolean;
/** Similar to `trimTagRight`, whereas the `\n` is exclusive. Defaults to `false`. See Whitespace Control for details. */