ReferenceError: luxon is not defined

I have this dataviewjs inline query to show me a link to today’s note:

$= dv.fileLink("Reviews/00 Dagen/" + luxon.DateTime.now().toISODate(), false, "Review van Vandaag") 

Unfortunately I get an error these last few days:

Dataview (for inline JS query ‘dv.fileLink(“Reviews/00 Dagen/” + luxon.DateTime.now().toISODate(), false, “Review van Vandaag”)’): ReferenceError: luxon is not defined

Apparently it’s got something to do with updates, because on mobile (android) it only happened after I updated all plugins.

I’ve searched both here and the dataview git, but I can’t find any solution. Maybe someone here can help out?

Which version of Obsidian / dataview are you using? It seems like a rather old variant since you’re still using luxon… Oh well…

Try the following:

Now as an ISO Date: `$= dv.date("now").toFormat("yyyy-MM-dd")`

Updated version of yours:  `$= dv.fileLink("Reviews/00 Dagen/" + dv.date("now").toFormat("yyyy-MM-dd"), false, "Review van Vandaag") `

Which produces this for me:
image

There are also options to use moment() within dataviewjs, but I find it a little confusing, as then all the momentjs date tokens are used, whilst when using dateformat and this toFormat the luxon date tokens are used. They are mostly the same, but there are differences, which I find a little confusing.

Take the following example:

luxon "DDDD" : `$= dv.date("now").toFormat("DDDD") `
moment "DDDD": `$= moment(dv.date("now")).format("DDDD") `

Which produces this output:
image

The first line is todays date in a localised format (that is Norwegian, by the way), and the second line lists the day of the year. Duh…

Some other differences:

  • d - day of the month vs day of week
  • dd - padded day of month vs two-letter day of week
  • YYYY - nothing vs years in four digits
  • S - millisecond, no padding vs fractional second (one digit)

And there are various format tokens only present in either variant, with Luxon having the most options (and they’ve got some many options that in itself is slightly confusing).

Update: By the way, you could also change your original reference to luxon into dv.luxon and get it working. Didn’t notice that before just now…

1 Like

Your solution worked beautifully! Thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.