2014-06-23 81 views
0

我需要以两种不同的格式显示以下Jekyll前端事件:用于JS库的军事格式和用于显示的标准格式。这似乎比它应该更复杂。有任何想法吗?如果有更好的方法来指定它,我愿意改变yaml的格式。将军事转换为标准时间

--- 
layout: event 
title: Big Air Trampoline Park Field Trip 
start: "13:00" 
end: "15:00" 

回答

1

我结束了创建一个包括这个,希望有人会提出一个更好的办法:

{% assign times = include.param | split: ':' %} 
{% assign h = times[0] | modulo:12 %} 
{% assign hh = times[0] | modulo:24 %} 

{% if h == 0 %}12{% else %}{{h}}{% endif %}:{{times[1]}} 
{% if h == hh %}am{% else %}pm{% endif %} 

我这样称呼它:

{% include display_time.html param=event.start %} 
相关问题