Usage of MomentJS formats

(Internal Link) ONE DATA Markup Language | APPS Documentation mentions the possibility to use MomentJS formats for Data/Time elements.
How can these formats be applied to

  1. HTML elements
  2. Columns in tables

The formatting strings are clear to me but since the lib examples is JS, I’m wondering on how to incorporate them into our elements.

As far as I understood for the configs “format” (depending on the data type) you can reference for possibilities at MomentJS and NumeralJS. So whenever an element offers you “format” than you can look up there the options, but not just at any place in the App config I would assume. (see Screenshot for a reference in the docu)

OK, this seems like the way to go. Unfortunately, column elements in tables do not have a dedicated format attribute (which tbh puzzles me a bit since I would expect this option exactly there as many other visual settings can be done there). I suppose, I somehow need to define an element in the columnStyles section in global and then reference it somehow.

Anyone with a working example?

Found it. The columnStyles attribute can be used inside elements. (Documentation is a bit confusing listing it in “Global” section).
This did the trick for me:

{
  "id": "elem_jobResults",
  "type": "table",
  "source": "src_job_list",
  "columnStyles": [
    {
      "name": "end_time",
      "format": "YYYY-MM-DD [at] hh:mm"
    }
  ],
  "syncSets": [
    {
      "syncSetId": "sync_project_filter",
      "publishFilters": false,
      "applyFilters": true
    }
  ],
  "@config": {
    "partial": "part_job_list_config"
  }
}

One thing remains: Can we also use functionality like the Time to now feature (see Moment.js | Docs) formatting the timestamp as time passed up to now (e.g. “a day ago”)? This would be the the optimal solution in my case.

Ah perfect that you found it, here also another hint for maybe other readers.

1 Like

Support for functions like “Time to now” is currently not implemented. But good point. We will keep that in mind and forward it to product management

1 Like