将军事转换为标准时间

时间:2014-06-23 06:49:08

标签: jekyll liquid

我需要以两种不同的格式显示以下Jekyll前端内容:JS库的军事格式和显示的标准格式。它似乎比它应该更复杂。有任何想法吗?我还可以更改yaml的格式,如果有更好的方式来指定它。

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

1 个答案:

答案 0 :(得分: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 %}
相关问题