如何在 Jekyll 中输入 YYYYMM 日期?

How to enter a YYYYMM date in Jekyll?

在 Jekyll 中应该如何输入日期?

我想在要在 Jekyll 中使用的 YAML 文件中输入日期 "August 2018"。我找到了很多关于如何格式化现有日期的信息,但几乎没有关于如何输入它们的信息。

我找到的最好的是 Date formatting, which implies that dates entered in ISO 8601 format should be valid. If I run with this, then Wikipedia explicitly states

"2004-05" is a valid ISO 8601 date, which indicates May (the fifth month) 2004.

这意味着 "August 2018" 可以输入为 2018-08

但是,当我在我的 _data 文件夹中使用我的 YAML 文件时 my_data.yml

date: 2018-08

然后 Jekyll 无法将其识别为日期

{{ site.data.my_data.date | time: '%B %Y' }}

输出“2018-08”而不是 "August 2018"。

TL;DR:输入 YYYYMM 日期,例如 "August 2018" 作为 Aug 2018

搜索 Jekyll repo, I found the date filters. The Ruby on Rails method .to_formatted_s (source) 似乎是其中大部分的关键。在该方法的源代码中,日期写为 Tue, 04 Dec 2007 00:00:00 +0000,我猜我应该写 Aug 2018。在 my_data.yml 中这样做,代码输出预期的“2018 年 8 月”。