Add Local Time type from TOML

When working with videos, it’s very common to specify a timecode. TOML supports this as “Local Time” formatted as HH:MM:SS. While Zola does seem to parse TOML files correctly, it doesn’t do anything with the “Local Time” data, and instead - using __tera_context, it looks like it has some weird internal field like $__TOML_private_time (or something similar).

I have been getting around this by just using a string and javascript, but it would be nice to have native support. For instance, something like {{ 00:01:52 | minutes }} => 1 would be nice to declare in templates e.g. for video listings

That’s toml-rs private date serialization. It’s causing quite a few headaches for the front-matter that is trying to do TOML → struct → JSON. Probably some cases are not handled properly still? Is that in the extra section of the front matter?

1 Like

It is in an external TOML data file. I would imagine the same behavior would happen if it was declared in front matter.

There is some code to translate those dates in the front-matter to strings, maybe we can reuse that in the load_data for TOML.

1 Like

I have added a test in https://github.com/getzola/zola/pull/644/commits/603906de854811bc4d2a30fb5b0efc2837d7b79e but I can’t seem to replicate the issue, it seems to work as expected there?
Do you have a sample file that is failing?

1 Like

I’ll take a look when I get home from work later today.