Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering erlang:now() is broken #27

Open
l1x opened this issue Dec 17, 2013 · 0 comments
Open

Rendering erlang:now() is broken #27

l1x opened this issue Dec 17, 2013 · 0 comments
Assignees
Milestone

Comments

@l1x
Copy link

l1x commented Dec 17, 2013

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!

@ghost ghost assigned zkessin Jan 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants