Skip to content

Rendering erlang:now() is broken #27

@l1x

Description

@l1x

Hi,

Having timestamps in you data is kind of standard, Rails has created_at and updated_at, etc. I was trying to do the same and included StartTime and EndTime in my model (kind of similar to the Rails timestamps but not quite).

After pulling up the records in CB_Admin it renders like this:

http://cl.ly/image/2P30381W3X2N

Here is the relevant code

cb_admin/src/view/model/show.html

{% if datatype == "datetime" %}
<span id="{{ record.id }}-{{ key }}">{{ val|date:"N j, Y, P" }}</span>
{% else %}

I am fairly new to CB so I had no idea what date:"N j, Y, P" is doing but I guess it is the same as in the Django template builtin.

https://docs.djangoproject.com/en/1.1/ref/templates/builtins/#date

Unfortunately you can't pass in the erlang:now() output to this built in function because it renders it incorrectly as you can see the screenshot above.

In Erlang I would fix it something like this:

{{Year,Month,Day},{Hour,Min,Sec}} = calendar:now_to_local_time(erlang:now()).
lists:flatten(io_lib:format("~p : ~p : ~p - ~p : ~p : ~p", [Year, Month, Day, Hour, Min, Sec])).

My question would be: how is this supposed to be fixed? Could I invoke an Erlang function from the template or I need to format the timestamp before I pass it in?

Thank you in advance!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions