🆕 Relative Time ("1 hour ago") Plugin

The Relative Time plugin transforms a date time value into a relative description like “2 hours ago.”

Please play with it and check out the documentation for the underlying library and give your feedback. There are some configuration options, and it seems to round pretty heavily, so we may need to tune it a bit.

27 Likes

Bravo :clap::clap::clap:

1 Like

This works for me in the Editor but does not display anything on my device. I have a feeling it’s a language issue, as my PC uses US English by default, but my Android phone uses Canada English.

Is there any way to make this work regardless of locale? I assume there would be issues with translating the text it generates, which could be why it only seems to work for US-language settings.

Edit: confirmed — I changed my device’s language to US English and it magically showed up in the app. If this can’t be forced to work with multiple locale’s, I recommend adding some hint text to the Plugin so users are aware of this limitation.

Edit2: just checked the gitlab details and there seems to be multiple languages set up already. From what I can tell, Canada English should still use the “en” abbreviation, but it’s not working. Is anyone aware of another English locale/abbreviation that needs to be added? Sorry, I’m not an experienced programmer, so I’ve likely butchered the description of this issue.

If there is, I’d love to know what it is!

I’ve basically given up on most of the Date Plugins, and especially the Format Date one. Sometimes it works, and sometimes it doesn’t. And whilst I’m fairly convinced it’s a regional problem, I’ve struggled to find any consistent and repeatable behaviour.

Most of the functionality they provide can already be achieved with a bit of date math, anyway.

1 Like

Shoots… the plugins are so awesome and simple though!

It looks as though other locales can be loaded into the script, but I guess I’d have to fork it and build out my own version to use in the Experimental Code column. Not my strength but I might give it a shot later.

If you’re going to go to that trouble (and you can make it work), then don’t forget to make locale a configuration option, and then send @david a Pull Request :stuck_out_tongue:

1 Like

Hi David, I noticed the Time Ago code column only supports English, as seen here:

Would it be possible to add a localization option for other languages, like German “de”? For example:
import de from "javascript-time-ago/locale/de.json";
This would be really helpful for international users. Thanks for considering!

Maybe try out the AI custom component

Thanks Jeremy, but I need to display the relative time (german format) in the table component. Please consider adding an option for localization:

@stefan you can do this, create a template column and change the english text with your language, see the image.

Attention: you have to put the plural translation before the singular version.

2 Likes

Great idea and solution! Thanks Antonino

1 Like