Date formatting daily note: `wo` incorrectly classified

after update to 1.11 Custom Format for the daily note is broken YYYY/MMMM/wo/ddd DD-MM-YYYY. YYYY/MMMM/w/ddd DD-MM-YYYY works, but adding o after w causes an error.
image

2 Likes

interesting

1 Like

Hello, this is a quirk/bug of momentjs who is able to output wo but not read it/parse it/validate it.

We won’t work on this. Sorry.

thanks for quick reply. but, this error never appeared before the update.

Because in 1.11 we reworked the settings and added validations in a bunch of places.

I don’t get it. Isn’t it validated like - just see if it returns “Invalid date”? If I put anything there, and it doesn’t spit out “Invalid date”, aren’t we good to go?

// Output today's date using 'wo' format
moment().format('wo') // returns '3rd'
// Validate a date that uses the 'wo' format
moment('3rd', 'wo', true).isValid() // returns false?!?

Right… but I don’t think we want to validate the object returned by moment(). We want to validate the format itself. Reconstruction of object from the format is way harder than validation of the format itself using a valid object.

Do we ever reconstruct moment() object from the format provided in the daily notes field? If not - validate the format, assume object correct. That’s it.

So:

function validate(userProvidedFormat) {
 var correctObject = moment(); // Assume correct object, by creating no fail path instance.
 return correctObject.format(userProvidedFormat) !== 'Invalid date';
}

It’s even better - I can’t fail the format() ever, it just works as long as the object is correct. The Daily Note literally can work on any string, as long as you feed the user-defined format with a valid moment() instance.

There’s just no way user can put in an Invalid date format. The means you’re trying to validate it with has larger scope than the user scenario of this field. And only then it fails.

Here’s the output of the text above when fed to format() on a valid moment instance - just to prove there’s no such thing as Invalid date format:

"It’37 0v0n b0tt0r - I cpmn’t fpmi3/15/2026 t100 for34pmt() 0v0r, it ju37t 12thr2237 pm37 3/15/2026ong pm37 t100 obj0ct i37 corr0ct. T100 15pmi3/15/20262026 ADot0 3/15/2026it0rpmMar 15, 20262026 cpmn 12thr22 on pmn2026 37tring, pm37 3/15/2026ong pm37 2026thu f000 t100 u370r-00fin00 for34pmt 12it10 pm vpm3/15/2026i0 34o340nt() in37tpmnc0. T100r0’37 ju37t no 12pm2026 u370r cpmn put in pmn Invpm3/15/2026i0 0pmt0 for34pmt. T100 340pmn37 2026thu’r0 tr2026ing to vpm3/15/2026i0pmt0 it 12it10 10pm37 3/15/2026pmrg0r 37cop0 t10pmn t100 u370r 37c0npmrio of t10i37 fi03/15/20260. PMn0 on3/15/20262026 t100n it fpmi3/15/202637."

+1 - would like to be able to use day ordinals here as in other locations in Obsidian e.g. Templates => Date format.

Assuming that you are parsing this to facilitate opening an existing daily note rather than creating duplicates? If so could the date not be stored as a Date property rather than encoded into the page title string? This is already automatable via Templates using {{date}}.

Anything new?